Skip to content

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

Merged
merged 1 commit into from
May 12, 2023

Conversation

oscargus
Copy link
Member

@oscargus oscargus commented Mar 5, 2023

PR Summary

Request for comments before adding tests and release note(?).

Partly motivated by the ugly center part of

image

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

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

@oscargus
Copy link
Member Author

oscargus commented Mar 5, 2023

This comment (and discussion in general): #24666 (comment) is probably relevant here as well.

However, one may want to add shadow_factor (bad name btw, but no idea for a better) and shadow_offset there as well.

Using shadow_props means we can skip shadow_factor to pie (and legend). But not so obvious if one should extract an offset argument to shadow_props or have it separate.

It is also worth noting that the shadow direction is different between pie and legend.

@oscargus oscargus force-pushed the pieshadow branch 2 times, most recently from 7f22f81 to 23f9569 Compare March 26, 2023 14:47
@oscargus oscargus marked this pull request as ready for review March 26, 2023 14:52
@oscargus oscargus force-pushed the pieshadow branch 3 times, most recently from 95e1383 to a39e43c Compare March 26, 2023 15:15
@oscargus oscargus added this to the v3.8.0 milestone Mar 26, 2023
Copy link
Member

@timhoffm timhoffm left a 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. 👍

Comment on lines 631 to 633
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*.
Copy link
Member

@timhoffm timhoffm Mar 26, 2023

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?

Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

@oscargus oscargus May 12, 2023

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.

@oscargus oscargus force-pushed the pieshadow branch 2 times, most recently from f289385 to f827da6 Compare March 30, 2023 08:01
@oscargus
Copy link
Member Author

oscargus commented Mar 30, 2023

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.

@tacaswell tacaswell merged commit 1e8821d into matplotlib:main May 12, 2023
@oscargus oscargus deleted the pieshadow branch May 18, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants