-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Implemented support for 'markevery' in prop_cycle #10713
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
Conversation
…plotlib into fixed-issue-8576
…mple code for markevery
…mple code for markevery
…b into fixed-issue-8576
Just a few preliminary requests:
|
Hi, thanks for the response. I've removed the issue number from the title and made the PR self contained with enough information about markevery and the issue this PR resolves. If I understood correctly, using the property beyond the example. The functionality for markevery is already supported within matplotlib. This PR just enables support for assigning a cycler object with markevery to axes.prop_cycle through the use of rcparams. Let me know if anything else needs to be done. |
@salindersidhu Thanks so much. Crystal clear now! I'll try an review when you are done. If you don't get feedback in a few days, feel free to ping... |
Done, all checks have passed! |
OK< sorry if I'm a lazy reviewer, but time is time. Is there no kwarg way to specify |
|
I get confused about the linestyle cycles. Maybe they are only implimented via rcParams? |
Sorry about the delay, after reading this link it turns out that we can assign
I've demonstrated this using the code below. from cycler import cycler
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
t = np.arange(0.0, 1.0, 0.01)
ax = plt.subplot(111)
ax.set_prop_cycle(markevery=[5])
ax.plot(t, np.sin(2*np.pi*t), marker='o')
plt.show() Upon testing this with the current stable version of matplotlib (2.2.0), I get the same ValueError as using |
Are you sure you checked all the files in? This PR doesn't touch any files to do with plotting or lines, so I don't see how it could have fixed anything... Sorry for the long process! |
The answer is found in this file /master/lib/matplotlib/axes/_base.py That file contains a class called The We can see that this cycler function is imported from rcsetup.py here /master/lib/matplotlib/axes/_base.py#L38 The cycler function in rcsetup.py validates the keywords from a dictionary containing a keyword and it's validator. This PR added This is the reason why the fix in this PR works for set_prop_cycle because it uses a cycler object from rcsetup.py |
Great detective work! Not at all obvious. |
Awesome, any ETA on when this will be merged? |
It needs two reviews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nicely done.
Thanks a lot @salindersidhu and thanks for patiently walking me through your changes! |
PR Summary
Closes issue #8576
This PR resolves a ValueError caused by assigning the axes.prop_cycle attribute, through rcParams, a cycler composed using a markevery value. Markevery is Line2D object property that is used to show a marker at actual data points along a plot. e.g., if markevery=[5], every 5-th marker will be plotted. Additional details about markevery and it's type constraints can be found here https://matplotlib.org/api/_as_gen/matplotlib.lines.Line2D.html#matplotlib.lines.Line2D.set_markevery
The following code replicates the ValueError mentioned above.
ValueError: Key axes.prop_cycle: Unknown artist properties: {'markevery'}
The following picture shows the above code functioning correctly, every 5th data point on the sine curve is marked.

I have extended rcsetup.py to include a markevery validator and the test cases for the markevery validator in test_rcparams.py. I have added the what's new entry for this fix and example code showcasing axes.prop_cycle configured through rcParams with valid use cases of markevery.
PR Checklist