Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[ENH]: fill_between invert? #23768

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

Open
mmakster opened this issue Aug 29, 2022 · 6 comments · May be fixed by #24742
Open

[ENH]: fill_between invert? #23768

mmakster opened this issue Aug 29, 2022 · 6 comments · May be fixed by #24742
Labels
Difficulty: Hard https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature

Comments

@mmakster
Copy link

Problem

It would be nice if matplotlib's fill_between could fill the regions below two intersecting lines and above both lines. It can fill between both lines, but I haven't found a simple way to invert the region obtained previously. The only workarounds I have are to create some extra functions, or to swap foreground and background, both of which are cumbersome. There is a related issue with figures and code on stackoverflow: https://stackoverflow.com/questions/73447993/matplotlib-fill-between-invert

r9AnS

Proposed solution

Adding a boolean "invert" argument to fill_between would be nice

@timhoffm
Copy link
Member

timhoffm commented Aug 29, 2022

Thanks for the suggestions. This is more complex than it may sound.

The "outside" area is vertically unbounded. We don't have Polygons that are partially unbounded. That means writing a new type of Artist. The first step in such a direction would be writing such an Artist and creating fill_below() and fill_above() functions. "Fill outside" would be an additional step that needs the intersection handling. I suspect also that it'd better be a dedicated function and not a variant of fill_between.

@mmakster
Copy link
Author

Thank you for your reply. How about using the y limits of the axes as a boundary? Is there some way to keep track of them if they change?

@tacaswell
Copy link
Member

I think we want a polygon where you can specify each point in a different coordinate system (aka transform) as what you really want for outer edges is a blended (data, axes) coordinate system and for the "inner" points you want a pure-data coordinate system.

https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.ConnectionPatch.html sort of does this, but only for two points

@tacaswell tacaswell added this to the v3.7.0 milestone Aug 30, 2022
@tacaswell tacaswell added the Difficulty: Hard https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label Aug 30, 2022
@timhoffm
Copy link
Member

@tacaswell maybe we should phrase this differently. In your proposal we'd need not only a different coordinate system per point, but per coordinate (x in data, y in axes). I'm not convinced we need this generality however. It may be simpler to regard the required Artist more like a line segment, which is extended to an "area" by going vertically/horizontally to +/-infinity.

@kaylinli
Copy link

kaylinli commented Dec 4, 2022

Hello, @Kevin1212918 @antarapal235 @jasonper0042 @ShakthiAngou and I are planning on working on this issue for a software engineering class.

@story645
Copy link
Member

story645 commented Dec 4, 2022

I'm not convinced we need this generality however

For #22409, @hoffm386 suggested filling the boundary region in a way where the fill would remain on zooming in and out.

@antarapal235 antarapal235 linked a pull request Dec 15, 2022 that will close this issue
6 tasks
@QuLogic QuLogic modified the milestones: v3.7.0, future releases Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Hard https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants