Skip to content

Fix pie chart in demo_agg_filter.py #24261

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 2 commits into from
Oct 25, 2022

Conversation

leejjoon
Copy link
Contributor

PR Summary

This fixes the pie chart in [demo_agg_filter.py] (https://matplotlib.org/stable/gallery/misc/demo_agg_filter.html) which is incorrectly displayed with simple black color . Fixed image is shown below. It also add new shrink parameter and a bit of more documentation.

image

PR Checklist

Tests and Styling

  • [N/A] Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).

@oscargus oscargus added this to the v3.6-doc milestone Oct 24, 2022
@ksunden
Copy link
Member

ksunden commented Oct 24, 2022

The implementation of shrink relies on scipy, which I do not believe we want to make a dependency for building the docs.

See, for example, the double pendulum example which implements the code in python rather than using a scipy method which would provide better results.

@oscargus
Copy link
Member

Good observation! (Should probably not approve stuff with a heavy cold...)

It would be great to get rid of the scipy dependency.

@leejjoon
Copy link
Contributor Author

The implementation of shrink relies on scipy, which I do not believe we want to make a dependency for building the docs.

Would it be okay if the example uses "shrink=None" so that importing scipy is bypassed?
I think the shrink option gives a more pleasing result, and it would be good if we can let the users play with it.
If this is not acceptable, I can simply remove the shrink option and its dependency on scipy.

@tacaswell
Copy link
Member

Welcome back @leejjoon !

@ksunden
Copy link
Member

ksunden commented Oct 24, 2022

I think the effect you are looking for can be had with library-native changes to the explode parameter rather than passing through scipy.ndimage.

Figure_1

Here is a quick example demonstrating the differences between the example as is (with your fixes so that it works, but without shrink, with your shrink implementation and with no shrink, but a uniform 0.1 for explode rather than (0, 0.05, 0, 0)

@leejjoon leejjoon force-pushed the fix_demo_agg_filter branch from 74c016d to 118bfcc Compare October 25, 2022 01:53
@leejjoon
Copy link
Contributor Author

Okay, I have removed shrink parameter so the scipy dependency. However, I still think that it would be good to have a shrink parameter as it offers a rather general solution not specific to pie chart.

I also have rebased the PR to the current main and force-pushed it.

@leejjoon
Copy link
Contributor Author

Welcome back @leejjoon !

Thanks!

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuLogic QuLogic modified the milestones: v3.6-doc, v3.6.2 Oct 25, 2022
@QuLogic QuLogic merged commit 96e69ed into matplotlib:main Oct 25, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Oct 25, 2022
@leejjoon leejjoon deleted the fix_demo_agg_filter branch October 25, 2022 06:26
oscargus added a commit that referenced this pull request Oct 25, 2022
…261-on-v3.6.x

Backport PR #24261 on branch v3.6.x (Fix pie chart in demo_agg_filter.py)
melissawm pushed a commit to melissawm/matplotlib that referenced this pull request Dec 19, 2022
* fix demo_agg_filter.py

* Update examples/misc/demo_agg_filter.py

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@ksunden ksunden mentioned this pull request Feb 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants