-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add configuration of Shadow and pie shadow #25389
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
This comment (and discussion in general): #24666 (comment) is probably relevant here as well. However, one may want to add Using It is also worth noting that the shadow direction is different between pie and legend. |
7f22f81
to
23f9569
Compare
95e1383
to
a39e43c
Compare
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.
I think the shadow parameter is in line with the legend shadow configuration #24666. 👍
lib/matplotlib/patches.py
Outdated
shade : float, default: 0.3 | ||
How the darkness of the shadow relates to the original color. If 0, the | ||
shadow is black, if 1, the shadow has the same color as the *patch*. |
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.
I think you need to reverse numbers to have reasonable semantics: High shade (=1) should be dark, low shade should be colorful; i.e. go with
default 0.7 and color = (1- shade) * np.asarray(...)
Alternatively we need a different name.
Not checked. Do we have something similar already in the library?
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.
I was also thinking about that, but couldn't really find something suitable. I think the 1 - shade
-solution is probably the easiest way out. I have not found anything similar at least, but may not really know what to search for.
https://en.wikipedia.org/wiki/Tint,_shade_and_tone#/media/File:Tint-tone-shade.svg
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.
If we are naming this now, can we go with "saturation" and follow the HSV / HSL conventions of 0 -> black 1 -> color?
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.
I went with the "inverted shade" (so the version of shade that makes sense). I guess saturation will work as well, just that the shading is done in RGB-space so not clear which is better. But easy to change if required.
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.
Is everybody fine with the shading in RGB space or do we need to look into saturation?
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.
I guess it should ideally be done in some other space, but since we started using RGB (although with a fixed value), maybe we do not want to change it? Either way, it seems to be a slightly different problem.
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.
Maybe one should add a color
argument to Shadow
as well that takes precedence if given? In that way people can rely on shade
if that gives good enough results or set whatever color they like and then benefit from the positioning etc.
Edit: ah, no need, one can just specify facecolor
.
f289385
to
f827da6
Compare
Updated with tests and an example. Also incorporated the only thing really "new" in https://matplotlib.org/stable/gallery/pie_and_polar_charts/pie_demo2.html (changing radius and font size) into https://matplotlib.org/stable/gallery/pie_and_polar_charts/pie_features.html So apart from the argument naming, there is nothing obvious from my side to add/modify now. |
PR Summary
Request for comments before adding tests and release note(?).
Partly motivated by the ugly center part of
which would be solved (in some sense), by adjusting the alpha.
An alternative is #3134 but quite a bit more work there.
(Marking as ready after three weeks without feedback.)
PR Checklist
Documentation and Tests
pytest
passes)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