-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update colormap usage documentation to prioritize string colormap names #29028
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
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.
@Kaustbh Sorry, I have not been clear on the intended change in #28915.
With the recommendation
So the recommendation would be:
- Use str colormap names on
cmap
arguments.- Use
plt.colormaps[name]
to get the colormap instance.
I primarily intended to change the way we access colormaps in the documentation; i.e. demonstrate by example. The concrete action is: "Go through our docs and apply these rules."
I'm a bit torn whether it's worth to spell the recommendations out explicitly for the user. While it gives direction, it's one more think to read/learn. Also, there's no canonical place to put that recommendation. It certainly does not belong in the diverging_colormaps what's new entry - that link was only where I saw the plt.cm*
use.
Okay, I will give it a try. |
Hi @timhoffm while going through the documentation I saw an example, https://matplotlib.org/stable/gallery/mplot3d/imshow3d.html#sphx-glr-gallery-mplot3d-imshow3d-py, in this example code,
which caused because we are having |
Please leave this as is for this PR - it’s off-topic. (General note: |
Thank you for the clarification! I understand that |
Yes. |
I have made the commit please review and suggest me any changes. |
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.
Almost good to go. Please still fix the flake8/precommit errors. - The failing test on OSX is unrelated.
Pre commit isort fails. I don’t see directly what is wrong in the code. Can you please check what code changes it suggests? |
Why are 132 files changed? Please don't changed unrelated files. |
I think it happened because of |
I assume, you have triggered isort locally and added all changes it has found? While I don't know why there are that many changes (maybe an update to isort?) these should not be part of this PR. We only want changes that are necessary in the context of this PR. Before your last force-push there have been two or three isort errors in the precommit action. Please do the following:
|
matplotlib/.pre-commit-config.yaml Lines 63 to 68 in f8900ea
|
If I have understood, all your deliberate changes are under
This checks out the |
@QuLogic can you please approve this PR or are there any changes to be made? |
Hi @QuLogic, I hope you're doing well. I am following up on my previous message regarding this PR. Please let me know if there are any changes I should make or if they are ready for approval. Thanks for your time! |
This will also need a rebase to fix the conflicts. |
@QuLogic please check the commit. |
The comments on |
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 good now.
Fixes: #28915
This update suggests using string colormap names directly for cmap arguments due to their readability and ease of use. The update also recommends plt.colormaps[name] to retrieve colormap instances, offering a scalable approach that supports both built-in and user-registered colormaps.