-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[MNT]: matplotlib.cycler and pyplot.cycler are different functions #26868
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 agree |
Good morning. I'm a new contributor and would like to understand what should be done. What we should do, then, is that when the pyplot.cycler function is called, matplotlib.rcsetup.cycler() is called instead. Did I understand correctly? |
The key thing to check (and I'm not familiar enough with the cycler logic to do this ad-hoc) is whether If that's the case, the fix is as easy as replacing matplotlib/lib/matplotlib/pyplot.py Line 54 in dfdb37a
by
The main task here is not the code change itself, but to understand the logic and be sure that the change would not break any users. |
I do believe they are signature compatible, though I will note that part of the validation done by
Is pyplot really a namespace we wish to advertise cycler is available at? I guess I would actually lean towards taking it out as an implementation detail rather than switching the source... (perhaps as part of a larger cleanup of the pyplot namespace, perhaps with deprecations, etc) if users want the existing cycler method that is there, it should be imported from cycler directly; if you want the validated one get it from rcsetup? I don't have a huge problem with making it technically available. It is not documented in that location (at least in api docs or our own examples; there is one "whats new" entry that uses |
cycler is too widely used to just rip it out: https://github.com/search?q=plt.cycler&type=code. Also, it feels too heavy to need an extra import to set a simple colorcycle. - Most of the time people just cycle one property. It might be an option to construct cyclers implicitly in the background, e.g.
That would alleviate the need for most Defering to 3.11. Edit: I just realized With very few exceptions, the other major usage of |
Summary
pyplot.cycler
is an (unused) import of the originalcycler.cycler()
function. This was originally imported in 0c1e609 to be used inside thexkcd()
function. It's probably not meant to be public, but as a matter of fact is now (https://github.com/search?q=plt.cycler&type=code). - We even have used it in an example in 3.4.0 What's new.matplotlib.cycler
ismatplotlib.rcsetup.cycler()
which is a wrapper aroundcycler.cycler()
and additionally includes validation.Proposed fix
Attention @ksunden:
pyplot.cycler
is not re-exported for typing, so we may see complaints about this in the near future.Generally, we should not expose two different cycler functions within matplotlib. It's questionable enough (though one can argue for it) that we provide a replacement for the original cycler.
Likely, the reasonable way forward is to expose
matplotlib.rcsetup.cycler()
inpyplot
.The text was updated successfully, but these errors were encountered: