Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CN colors look up the global prop_cycle at draw time rather than the axes' one. #9842

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

Closed
anntzer opened this issue Nov 23, 2017 · 3 comments
Closed
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Nov 23, 2017

Bug report

Bug summary

http://matplotlib.org/devdocs/tutorials/colors/colors.html states that

a “CN” color spec, i.e. 'C' followed by a single digit, which is an index into the default property cycle (matplotlib.rcParams['axes.prop_cycle']); the indexing occurs at artist creation time and defaults to black if the cycle does not include color.

In particular, this implies that the lookup is not performed on the Axes' prop_cycle (but the global one), which is the actual behavior, may be a bit strange but I guess is OK.
On the other hand, the look up definitely occurs at draw time and not at artist creation time:

Code for reproduction

from pylab import *

gca().set_axis_off()
l, = plt.plot([1, 2], c="C0")
rcParams["axes.prop_cycle"] = cycler(color=["r", "g", "b"])
print(l.get_color())
show()

Actual outcome

outputs 'C0' and a red line, not a tab:blue one.

Expected outcome

We need to discuss whether the doc is wrong or the behavior is wrong...

Matplotlib version

  • Operating system:
  • Matplotlib version: master (there was some refactoring in New color conversion machinery. #6382 but looking at the diff it is clear that the current behavior was already present earlier).
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version:
  • Jupyter version (if applicable):
  • Other libraries:
@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 25, 2023
@tacaswell
Copy link
Member

The docs are wrong, at the time we resolve 'CN', we have no way of knowing what Axes we are going to be associated with.

@github-actions github-actions bot removed the status: inactive Marked by the “Stale” Github Action label Apr 26, 2023
@QuLogic
Copy link
Member

QuLogic commented Apr 26, 2023

The docs say "at draw time" and have done so since #12598.

@QuLogic QuLogic closed this as completed Apr 26, 2023
@QuLogic QuLogic added this to the v3.1.0 milestone Apr 26, 2023
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