pyplot以交互模式显示大量数字 [英] pyplot display large numbers in interactive mode
问题描述
我正在尝试使用交互模式在x轴上绘制大量数字,而不是刻度上的完整数字,我得到1、1.5等,以+ 5.043e3.我如何显示完整号码?
I'm trying to plot large numbers on the x axis using the interactive mode, and instead of the full number on the ticks, i get 1, 1.5 and so on and +5.043e3. how can i display the full number?
定义plt.ion()
后,我将其放在循环中:
After defining the plt.ion()
, i have this inside a loop:
plt.xlabel("Wavelength (angstroms)")
plt.ylabel("Arbitrary Flux")
plt.plot(xo,yo,'k--')
for e in range(multispec):
if ( e == 0):
plt.plot(MX[e],MY[e], 'r-')
else:
plt.plot(MX[e],MY[e])
l=float(int(n))
plt.axis([n-1, n+1, 0.1, 1.1])
n是for中定义的其他变量.
n is other variable defined in a for.
推荐答案
The formatting of tick labels is controlled by a Formatter
object, which assuming you haven't done anything fancy will be a ScalerFormatter
[by default][1]. This formatter will use a constant shift if the fractional change of the values visible is very small. To avoid this, simply turn it off:
plt.plot(arange(0,100,10) + 1000, arange(0,100,10))
ax = plt.gca()
ax.get_xaxis().get_major_formatter().set_useOffset(False)
plt.draw()
如果您想避免普遍采用科学计数法,
If you want to avoid scientific notation in general,
ax.get_xaxis().get_major_formatter().set_scientific(False)
这篇关于pyplot以交互模式显示大量数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!