-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Regression: undocumented change of behaviour in mpl 3.4.2 with axis ticks direction #20219
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
Comments
I think there is a strong case that the 3.4.1 behavior was buggy (as This is one of the fun things of working on a widely used library: all possible observed behavior eventually becomes a feature to at least one user (see https://xkcd.com/1172/)! If you want to have the default direction of the ticks be in I would use import matplotlib.pyplot as plt
plt.rcParams['xtick.direction'] = plt.rcParams['ytick.direction'] = 'in' |
I'm fine either way, though if you're considering it a bugfix I think it should be documented as such :-) |
@jklymak @tacaswell is there any relevant change or discussion about this ? should the new behaviour just be regarded as the new standard onwards ? |
I guess it depends on whether other tick params are persistent or not. Similarly other axes amd axis properties. If I change the face color does that reset in cla? I thought that cla simply removed any artists and reset any limits, but you could imagine it also scrubbing any axes styling. |
@neutrinoceros I'm still pretty convinced that the ticks not getting re-set was a bug and |
@tacaswell this makes sense to me. Should I move forward and open a PR to document this as the canonical/expected behaviour ? |
import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl
fig, ax = plt.subplots()
ax.set_facecolor('r')
ax.cla()
plt.show() shows a red axes, so I don't think its true that clearing the axes gives us a "new" axes; it clears the children. |
Maybe we should document
and also add a retro-active behavior change note to https://github.com/matplotlib/matplotlib/blob/master/doc/api/prev_api_changes/api_changes_3.4.2.rst If someone where to report Jody's example as a bug I would agree it was a bug. On the other had I bet the behavior has been like that forever and we do not want to wantonly break users. |
I think we should specify which properties will be reset and not change them arbitrarily. I think "some properties" is too vague. Axes.cla does lots of stuff, much of which seems concerned with initial setup of the axes. But it does try to explicitly preserve a bunch of things as well. |
You are right, but I do not like it. |
Bug report
Bug summary
Ticks direction set with
Axes.tick_params
used to be persistent but is now erased byAxes.cla()
.Maybe this change is actually intended ? in any case I couldn't find a mention of it in your release notes so I'm considering it a bug for now.
Code for reproduction
I originally detected a regression in yt, see yt-project/yt#3256
I was able to reproduce the change of behaviour with the following minimal script
Actual outcome
This is with matplotlib 3.4.2
Expected outcome
This is with matplotlib 3.4.1

Matplotlib version
import matplotlib; print(matplotlib.__version__)
): see aboveprint(matplotlib.get_backend())
): MaxOSXinstalled from pypi with pip
The text was updated successfully, but these errors were encountered: