You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression: undocumented change of behaviour in mpl 3.4.2 with axis ticks direction #20219
Ticks direction set with Axes.tick_params used to be persistent but is now erased by Axes.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
I think there is a strong case that the 3.4.1 behavior was buggy (as ax.cla() should set the axes back to its "fresh" state).
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
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 ax.cla() should take it back to an identical state to as when it was created. This is in part because it is easy to document and understand ("it makes it like new!" is simpler than "It makes it like new except for....") and because we use self.cla() as part of the initialization process of Axes.
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.
Activity
jklymak commentedon May 13, 2021
This bisects to #20161 @timhoffm if you had a chance to take a look? It looks like resetting all the kwargs in
clearwas too aggressive.tacaswell commentedon May 13, 2021
I think there is a strong case that the 3.4.1 behavior was buggy (as
ax.cla()should set the axes back to its "fresh" state).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
neutrinoceros commentedon May 13, 2021
I'm fine either way, though if you're considering it a bugfix I think it should be documented as such :-)
neutrinoceros commentedon Aug 5, 2021
@jklymak @tacaswell is there any relevant change or discussion about this ? should the new behaviour just be regarded as the new standard onwards ?
jklymak commentedon Aug 5, 2021
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.
tacaswell commentedon Aug 5, 2021
@neutrinoceros I'm still pretty convinced that the ticks not getting re-set was a bug and
ax.cla()should take it back to an identical state to as when it was created. This is in part because it is easy to document and understand ("it makes it like new!" is simpler than "It makes it like new except for....") and because we useself.cla()as part of the initialization process ofAxes.neutrinoceros commentedon Aug 5, 2021
@tacaswell this makes sense to me. Should I move forward and open a PR to document this as the canonical/expected behaviour ?
jklymak commentedon Aug 5, 2021
shows a red axes, so I don't think its true that clearing the axes gives us a "new" axes; it clears the children.
tacaswell commentedon Aug 5, 2021
Maybe we should document
claasand 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.
jklymak commentedon Aug 6, 2021
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.
tacaswell commentedon Aug 9, 2021
You are right, but I do not like it.