Question

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?

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 is other variable defined in a for.

Was it helpful?

Solution

[copied from How to prevent numbers being changed to exponential form in Python matplotlib figure ]

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top