Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticklabel format not preserved after editing plot limits #6276

Closed
peytondmurray opened this issue Apr 6, 2016 · 2 comments
Closed

Ticklabel format not preserved after editing plot limits #6276

peytondmurray opened this issue Apr 6, 2016 · 2 comments

Comments

@peytondmurray
Copy link

Version: 1.5.1, Windows 7, using QT5 backend. Not tested on linux yet. After setting the format of an axis to use use scientific notation,

ticklabel_format(style='sci', axis='y', scilimits=(0,0))

changing the limits of the plot using the green checkbox widget in the NavigationToolbar will remove the scientific notation formatting that was just set. This would be a huge convenience for users who use scientific notation and want to work with plots interactively. Example:

import matplotlib
matplotlib.use("Qt5Agg")
from numpy import *
from matplotlib.pyplot import *
from numpy.random import uniform

npts = 1000

x = uniform(-100, 100, npts)
y = 1000*sin(x)*cos(x**2)

plot(x, y)
ticklabel_format(style='sci', axis='both', scilimits=(0,0))

show()
@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Apr 7, 2016
@tacaswell
Copy link
Member

It is the set_*scale calls which remove the formatting.

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Apr 8, 2016
Only try to set the axis scales if they have been changed.

closes matplotlib#6276

The `set_yscale` and `set_xscale` Axes methods call out to
`Axis_set_scale` which resets the default locator/formatters (which
makes sense when flipping between log/linear).

Putting the cut-out in `figureoption` is the less disruptive change,
even if the case could be made that the no-op short-circuit should be
done in Axis or Axes.
@tacaswell tacaswell self-assigned this Apr 8, 2016
@tacaswell tacaswell modified the milestones: 1.5.2 (Critical bug fix release), 2.0.1 (next bug fix release) Apr 8, 2016
@gepcel
Copy link
Contributor

gepcel commented Apr 24, 2016

I think this might be relevant.

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()

works fine. But if ticklabel_format is put before set_major_formatter, it doesn't work.

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()

tacaswell added a commit to tacaswell/matplotlib that referenced this issue May 22, 2016
Only try to set the axis scales if they have been changed.

closes matplotlib#6276

The `set_yscale` and `set_xscale` Axes methods call out to
`Axis_set_scale` which resets the default locator/formatters (which
makes sense when flipping between log/linear).

Putting the cut-out in `figureoption` is the less disruptive change,
even if the case could be made that the no-op short-circuit should be
done in Axis or Axes.
anntzer pushed a commit to anntzer/matplotlib that referenced this issue Jul 24, 2016
Only try to set the axis scales if they have been changed.

closes matplotlib#6276

The `set_yscale` and `set_xscale` Axes methods call out to
`Axis_set_scale` which resets the default locator/formatters (which
makes sense when flipping between log/linear).

Putting the cut-out in `figureoption` is the less disruptive change,
even if the case could be made that the no-op short-circuit should be
done in Axis or Axes.

Closes matplotlib#6281
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants