y 轴的数值大时如何全写? [英] How to write the values of the y-axis in full when they are large numbers?

查看:62
本文介绍了y 轴的数值大时如何全写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我绘制 plt.scatter([0,1,2,3,4,5],[10001,10002,10003,10004,10005,10006]) 时,我得到了这个图:

When I am plotting plt.scatter([0,1,2,3,4,5],[10001,10002,10003,10004,10005,10006]), I obtain this figure :

我认为当我绘制大值的微小变化时,这些值不会直接写在 Y 轴上,而是被 1、2、3、4、5、6 + 1e4 代替.

I think that as I plot small variations of large values, the values are not written directly on the Y-axis and are replaced by 1, 2, 3, 4, 5, 6 + 1e4.

有没有办法强制直接写y轴值:10001, 10002, 10003 ,... ?

Is there a way to force the direct writing of the y-axis values: 10001, 10002, 10003 ,... ?

我没有在文档中找到任何内容matplotlib.pyplot.scatter.

I haven't found anything on the doc matplotlib.pyplot.scatter.

推荐答案

基于这里的答案:如何在 matplotlib 中用逗号将轴数字格式格式化为千位?,我建议使用以下方法:

Based on the answers here: How do I format axis number format to thousands with a comma in matplotlib?, I would recommend somthing like:

from pylab import *
plt.scatter([0,1,2,3,4,5],[10001,10002,10003,10004,10005,10006]);
gca().yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
show();

你改进了这个!

这篇关于y 轴的数值大时如何全写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆