-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Milestone
Description
Example:
I want to set ticklabel's as scilimits=(-3, 3) and useMathText=True.
This is what works:
plt.plot(1, 10000, 2, 20000, 'ro')
ax = plt.gca()
ax.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter(useMathText=True))
ax.ticklabel_format(scilimits=(-3, 3)) # put after 'set_major_formatter', scilimits works
plt.show()And this is what doesn't work, by switching two line.
plot(1, 10000, 2, 20000, 'ro')
ax = gca()
ax.ticklabel_format(scilimits=(-3, 3)) #put before 'set_major_formatter', scilimits doesn't work.
ax.yaxis.set_major_formatter(mpl.ticker.ScalarFormatter(useMathText=True))
plt.show()Reason:
This is what I've find out, I'd like to help, but I don't know weather this should be fixed or how this can be fixed.
In the source code here, every time a ScalarFormatter class was called, those two values (formatter.scientific, and formatter.scilimits) was reset.
Something to mention:
- In matplotlib, there are always many more better ways to one same thing. If anyone know some more elegant way of doing this, please let me know. And this way of setting scilimits and useMathText is what I've learned from this very good tutorial.
- I've made a commented about this in Ticklabel format not preserved after editing plot limits #6276 . But I'm sure they are relevant or not, so I'm filling this issue here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels