-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
added option to get_cmap("random") in cm.ColormapRegistry #24340
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
The head ref may contain hidden characters: "get_cmap(\"random\")"
added option to get_cmap("random") in cm.ColormapRegistry #24340
Conversation
…thod FIX: add missing method to ColormapRegistry
Bump version when invalid hatches error
DOC: align contour parameter doc with implementation
Due to inconsistencies in the colormap setup, it is suggested to instead check for `get_array` to get an array of values to be color mapped. This check is more robust irrespective of whatever the type of colormap is set to be.
Tests are added to check various conditions for the text color for a legend set with `linecolor`, `markeredgecolor`, `markerfacecolor` in a scatter plot.
) * ENH: Add pan and zoom toolbar handling to 3D Axes 1) This moves the pan logic that was already in the mouse move handler into the "drag_pan" method to make it available from the toolbar. 2) This expands upon the panning logic to enable a zoom-to-box feature. The zoom-to-box is done relative to the Axes, so it shrinks/expands the box as a fraction of each delta, from lower-left Axes to lower-left zoom-box. Thus, it tries to handle non-centered zooms, which adds more cases to handle versus the current right-click zoom only scaling from the center of the projection. * Rewrite zooming with bounding box * Rewrite 3d panning to work with a roll angle * Whats new for zoom and pan buttons * Make pan button configurable * Do not jump when zooming and mouse goes over other subplot * Rework zooming for 3d plots * Handle x/y lock when zooming and panning * Update tests * Docstrings * Dont assume a scale_z * Limit zoom box * Test zoom pan key modifiers * Save some calculation by saving view axes * Deprecation warnings for Axes3D.eye, .vvec * Remove Axes3D._prepare_view_from_bbox for now * Comments and docstrings * Switch from uvn to uvw * Save aspect to axes * Constrain zooming with mouse when one of the equal aspect ratios is set * Cleanup * Cleanup * Consolidate finding equal aspect axis indices * linting * More intuitive scaling * Box zoom keeps existing aspect ratios * Linting * Code review comments * Revert parameters for view_transformation * Fix new 3d pan/zoom view going on view stack twice * Better clipping * Test 3d toolbar navigation * Privatize helper functions * Deprecations * Code review changes * Deprecation note * Undeprecate proj3d.view_transformation * Undeprecate proj3d.view_transformation * Update doc/api/next_api_changes/deprecations/23449-SS.rst Co-authored-by: Greg Lucas <[email protected]> Co-authored-by: Scott Shambaugh <[email protected]> Co-authored-by: Oscar Gustafsson <[email protected]>
Inherit OffsetBox.get_window_extent.
Expire deprecations in dates and ticker
[DOC] Fix some documentation typos
Add QuadContourSet.remove.
ContourLabeler previously optionally used a custom Text subclass to ensure that text rotation took place in data space, not in screen space, but this is now available for all Text instances via the transform_rotates_text property, so directly use that. This means that _get_label_text, _add_label, and set_label_props can also directly get inlined into their now only callsite (add_label).
Replace ClabelText by set_transform_rotates_text.
The deprecated attributes cannot be updated after the ContourLabeler has been set up (i.e. if the end user overwrites them it does not update the labels) *and* all have direct replacements available. We could consider later adding new getters/setters (`get/set_font_properties`) which would actually update the properties on the label texts. While at it, prefer using `manual` over the equivalent but longer `self.labelManual`; `_get_nth_label_width` doesn't need to explicitly set the text size as that info is also carried by the fontproperties object.
* Add note about blitting and zorder in animations Co-authored-by: Tim Hoffmann <[email protected]> Co-authored-by: Elliott Sales de Andrade <[email protected]> Co-authored-by: hannah <[email protected]>
MNT: Clean up code in SecondaryAxis
Simplest pyproject.toml containing build-system only
…ypa/cibuildwheel-2.11.2 Bump pypa/cibuildwheel from 2.11.1 to 2.11.2
Small cleanups to QuiverKey.
show axes changing in animate decay example
Simplify generate_fontconfig_pattern.
Unify logic of ConnectionStyle._Base.{_clip,_shrink}.
Fix some minor docstring typos
GOV: change security reporting to use tidelift
Compare with the docstring of ImageMagickFileWriter just below.
Fix missing word in ImageMagickWriter docstring.
Update example and docstring to encourage the use of functools.partial in FuncAnimation
Add shading of Poly3DCollection
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Thank you for your interest in contributing to Matplotlib! Firstly, all PRs should be made to the For more complete description see our PR Guidelines I'm struggling to think of a use-case where it makes sense to blindly grab a random colormap. Color map choice is deeply tied to the kind of data you are visualizing: e.g. do you want a sequential colormap versus diverging or categorical? Could you clarify why you feel this is needed? |
Thanks for the initiative to contribute! However, I decline this feature. It's very rare that people want a random colormap. Usually you want to control your output. Moreover, different kinds of colormaps (linear, biopolar, ...) are suited for different kinds of data, so I strongly advise against using a random colormap. That said, if you really want a random colormap you can easily get one using builtin functionality:
or use |
Hello!
Thanks for replies. Looking more into contribution mechanics so I can put
together more organized PRs in the future.
Your audience definitely wants a "random" option! I've watched people -
instructors, even - spend minutes looking through your options and* trying
a bunch until they get one their gut likes.*
Also, importing additional libraries and using them on an object called
plt.colormaps may be beyond the desires of your users, man! Try googling
<https://www.google.com/search?q=get+random+colormap+from+matplotlib> for
that solution you made. Especially for people who haven't found their
favorites yet, ie. newbies.
Two lines of code, and the ability for people to quickly explore the
options your package offers. What a deal! All I'm saying. I'd be happy to
make a better PR, make "random" spit out the colormap so users can remember
it, but this one's a no-brainer, IMO.
Anyways, understood. Thanks again, and good luck.
…On Wed, Nov 2, 2022 at 1:24 PM Tim Hoffmann ***@***.***> wrote:
Closed #24340 <#24340>.
—
Reply to this email directly, view it on GitHub
<#24340 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3FFWYE656LFYP65E3Y3JH3WGKPWLANCNFSM6AAAAAARURP7AY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
August Van Hout
***@***.***
734-395-7160
|
It looks like many of those folks are trying to solve a different problem, which is distinct colors for categories, and distinctpy is a good solution that we could probably advertise more.
I agree that's a real problem, would something like a
and prints all the colormaps, but would something more condensed be a better way of approaching this problem? |
I’d argue that “random” is the best solution because it’s the simplest!
After all, if a user is familiar enough with matplotlib to get a random
colormap out of it, then they probably found their go-to three already.
And it’s easy as pie to implement! Besides, if people keep scrolling
through cmaps, might as well make it as easy as passing “random”. Frankly,
trying a bunch of colormaps is part of the fun of learning the package.
I think my PR has a long way to go, and I’d be happy to put a good one in
front of you so you can see how it feels in practice.
Thanks for the chance to advocate for the idea, very cool to interact with
y’all.
On Wed, Nov 2, 2022 at 4:24 PM hannah ***@***.***> wrote:
try googling
https://www.google.com/search?q=get+random+colormap+from+matplotlib for
that solution you made.
It looks like many of those folks are trying to solve a different problem,
which is distinct colors for categories, and distinctpy
<https://github.com/alan-turing-institute/distinctipy> is a good solution
that we could probably advertise more.
I've watched people - instructors, even - spend minutes looking through
your options and* trying a bunch until they get one their gut likes.*
I agree that's a real problem, would something like a plt.colormaps.list()
method that displays all the colormaps work better? That's currently
achievable in notebooks as
from IPython.display import display
for cm in plt.colormaps.keys():
display(plt.colormaps[cm])
and prints all the colormaps, but would something more condensed be a
better way of approaching this problem?
—
Reply to this email directly, view it on GitHub
<#24340 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3FFWYA7265W2L4Q5N5VLR3WGLEZRANCNFSM6AAAAAARURP7AY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
August Van Hout
***@***.***
734-395-7160
|
But guaranteeing no duplicates in the random in each session is probably a lot of code overhead, so aren't you betting on them finding one they like fairly quickly? And if they don't, my guess is it ends up as a more exhaustive search than printing the maps w/o the benefit of seeing the other options? To be clear, while I think random is really fun and I kinda want it as a bot, I agree with Kyle and Tim that I'm having trouble seeing it as in scope for the library for the reasons they mentioned. |
Alrighty!
I made a video of me trying this functionality out on a map of Melbourne,
Australia home prices.
Right here, two minutes long:
https://user-images.githubusercontent.com/1300499/199647564-8005fd2c-6904-47f4-890a-1f5a8a698ed6.mp4
I truly believe this belongs in matplotlib, and that passing cmap =
"random" is the intuitive way for end-users to experiment with many cmaps
very quickly. After all, many of us see cmaps as strings to pass to a
plotting function!
Thanks very much for taking the time with me. Whatever the outcome, there's
amazing stuff in the package and I'm glad y'all maintain it. Thanks.
…On Wed, Nov 2, 2022 at 5:31 PM hannah ***@***.***> wrote:
Besides, if people keep scrolling through cmaps, might as well make it as
easy as passing “random”.
But guaranteeing no duplicates in the random in each session is probably a
lot of code overhead, so aren't you betting on them finding one they like
fairly quickly? And if they don't, my guess is it ends up as a more
exhaustive search than printing the maps w/o the benefit of seeing the
other options?
To be clear, while I think random is really fun and I kinda want it as a
bot, I agree with Kyle and Tim that I'm having trouble seeing it as in
scope for the library for the reasons they mentioned.
—
Reply to this email directly, view it on GitHub
<#24340 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3FFWYCEL2ZPLJKPYZA44GDWGLMTTANCNFSM6AAAAAARURP7AY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I edited your comment so it links to the github upload of your video 'cause I figure folks (like me) would be a little freaked at clicking a random download link |
Thank you.
…On Thu, Nov 3, 2022 at 12:29 AM hannah ***@***.***> wrote:
I edited your comment so it links to the github upload of your video
'cause I figure folks (like me) would be a little freaked at clicking a
random download link
—
Reply to this email directly, view it on GitHub
<#24340 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3FFWYALENJUIOFYFDES423WGM5SLANCNFSM6AAAAAARURP7AY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
August Van Hout
***@***.***
734-395-7160
|
So I really want your video for the matplotlib instagram/tiktok/twitter, where I can share it w/ the code. Your video also sold me on a new example in the colors section of the gallery showing this since that section is kind of sparse and we can title it |
Wow! I’m flattered and of course.
On Thu, Nov 3, 2022 at 12:37 AM hannah ***@***.***> wrote:
So I really want your video for the matplotlib instagram/tiktok/twitter,
where I can share it w/ the code.
Your video also sold me on a new example in the colors
<https://matplotlib.org/devdocs/gallery/index.html#color> section of the
gallery showing this since that section is kind of sparse and we can title
it getting a random colormap from the colormap.registry 'cause we don't
really have a demo of that, it's all reference. <- this though would need
support of a second dev since we have way 660+ examples.
—
Reply to this email directly, view it on GitHub
<#24340 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3FFWYA472NOBAJ722RR7X3WGM6SBANCNFSM6AAAAAARURP7AY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
August Van Hout
***@***.***
734-395-7160
|
PR Summary
Added option to pass the string "random" to get_cmap function within cm.ColormapRegistry class.
Two lines of code, just looks up a np.random.choice(_colormap) from mpl.colormaps and returns it
First pull request, any advice welcome. Added some comments, change is tiny.
Thanks very much.
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst