pyplot以交互模式显示大量数字 [英] pyplot display large numbers in interactive mode

查看:96
本文介绍了pyplot以交互模式显示大量数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用交互模式在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.

推荐答案

[从刻度标签的格式由Formatter对象控制,假设您没有做任何花哨的操作,它将是ScalerFormatter [默认情况下] [1].如果可见值的分数变化很小,则此格式化程序将使用恒定移位.为避免这种情况,只需将其关闭:

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屋!

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