added random colormap option to cm.py (lines 705-740ish) - #24396
added random colormap option to cm.py (lines 705-740ish)#24396augustvanhout wants to merge 1 commit into
Conversation
|
@augustvanhout thanks so much for your enthusiasm! However, maybe the level of consensus wasn't clear in #24340 because only two maintainers directly engaged. I am also strongly against this. I think if anyone disagreed with @timhoffm about closing the PR, we would have said. Hopefully we hear from you again, perhaps with a cool example as suggested by @story645 |
|
Hello,
Understood. I’ll find some bugs to stomp… and maybe someday invent
something more nuanced!
Thanks for the responses. The learning experience has been important.
-Augie
On Mon, Nov 7, 2022 at 8:20 PM Jody Klymak ***@***.***> wrote:
@augustvanhout <https://github.com/augustvanhout> thanks so much for your
enthusiasm! However, maybe the level of consensus wasn't clear in #24340
<#24340> because only two
maintainers directly engaged. I am also strongly against this. I think if
anyone disagreed with @timhoffm <https://github.com/timhoffm> about
closing the PR, we would have said. Hopefully we hear from you again,
perhaps with a cool example as suggested by @story645
<https://github.com/story645>
—
Reply to this email directly, view it on GitHub
<#24396 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3FFWYG575W57ZHZD76PD4LWHGTG3ANCNFSM6AAAAAARZYFPE4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
August Van Hout
***@***.***
734-395-7160
|
Turning this PR into a documentation PR is mostly the same code you used to make your video, but placed in https://github.com/matplotlib/matplotlib/tree/main/examples/color @jklymak agreed that the example idea could work and for most docs you need one maintainer in agreement (here you've kinda got two) and nobody in opposition so far. |

PR Summary
Original PR #24340
Matplotlib has a huge number of colormaps and no way to quickly sample them! The above PR's comments contain spirited debate and a video of the proposed functionality - passing the argument 'cmap = "random"'
This PR adds a few lines to cm.py to allow coders everywhere to sample matplotlib's many colormaps on any plot they like, anytime they like.
Two things are changed in cm.py:
1) added one-liner function get_random_cmap() which returns a Colormap at random from _colormaps
2) added if statement to _ensure_cmap so that when a user passes "random" as a colormap, _ensure_cmap returns get_random_cmap()
And that's it.
The workflow was:
- Edit cmp.y and test functionality in venv
- Ensure flake8
- Run pytest - 1 depreciation warning when pickling
- Edit docstrings - went with precedent of other similarly short functions in cm.py
- Did not edit whats_new_next as feature is small
Attached is an example dataset (credit to Kaggle) as well as a script called random_colormap_test.py, which showcases the changes proposed.
melbourne.csv
random_colormap_test.txt
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).Documentation
Release Notes
[N/A] New features are marked with a
.. versionadded::directive in the docstring and documented indoc/users/next_whats_new/[N/A] API changes are marked with a
.. versionchanged::directive in the docstring and documented indoc/api/next_api_changes/[N/A] Release notes conform with instructions in
next_whats_new/README.rstornext_api_changes/README.rst