Matplotlib:-如何在刻度线上显示所有数字? [英] Matplotlib: -- how to show all digits on ticks?
问题描述
可能重复:
如何删除matplotlib轴上的相对位移
Possible Duplicate:
How to remove relative shift in matplotlib axis
我要针对日期绘制具有五个数字(210.10、210.25、211.35等)的数字,我希望y轴刻度线显示所有数字("214.20"而不是"0.20 + 2.14e2")而且还无法弄清楚这一点.我试图将ticklabel格式设置为纯格式,但似乎没有效果.
I'm plotting numbers with five digits (210.10, 210.25, 211.35, etc) against dates and I'd like to have the y-axis ticks show all digits ('214.20' rather than '0.20 + 2.14e2') and have not been able to figure this out. I've attempted to set the ticklabel format to plain, but it appears to have no effect.
plt.ticklabel_format(style ='plain',axis ='y')
plt.ticklabel_format(style='plain', axis='y')
任何明显的我想念的提示吗?
Any hints on the obvious I'm missing?
推荐答案
You can also just turn the offset off: (almost exact copy of How to remove relative shift in matplotlib axis)
import matlplotlib is plt
plt.plot([1000, 1001, 1002], [1, 2, 3])
plt.gca().get_xaxis().get_major_formatter().set_useOffset(False)
plt.draw()
这将获取当前的axes
,获取x轴axis
对象,然后获取主要的格式化程序对象,并将useOffset
设置为false(
This grabs the current axes
, gets the x-axis axis
object and then the major formatter object and sets useOffset
to false (doc).
这篇关于Matplotlib:-如何在刻度线上显示所有数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!