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

Skip to content

Add Axes.fill_disjoint to make invert fill_between easier #24742

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

antarapal235
Copy link

@antarapal235 antarapal235 commented Dec 15, 2022

PR Summary

This PR fixes #23768, which asks for an easy solution to invert the fill between 2 lines. In this PR, we wrote a new patch called Lines which bounds the y axis and fixes the unbounded limits problem discussed in the issue. We also wrote the function fill_disjoint which fills in the area excluding the region in between the lines bounded by (x, y1) and (x, y2), which are inputted into the function. Thus, these changes allow users to invert fill of simple shapes composed of straight lines.

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

Copy link

@github-actions github-actions bot left a 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.

Copy link
Member

@oscargus oscargus left a comment

Choose a reason for hiding this comment

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

Thank you for this! I just left some minor comments for now.

The image test.png should be removed as it is not used(?).

This is a good start (and the code quality is high, with good documentation!), but expect that there are things to be discussed.

For your info: we are in the final stages of feature freezing 3.7, so it may take a while before you get proper feedback (or it may not).

This could also do with a release note. Although in some sense it is OK to wait with that until the reviews start to converge, it can also be a good option to highlight the feature. For example, showing off different options and capabilities. See, e.g., https://github.com/matplotlib/matplotlib/blob/main/doc/users/next_whats_new/ellipse_annotation.rst what it may look like. (In your case I would go with a subplot with few different plots.)

@@ -1066,6 +1066,123 @@ def set_data(self, values=None, edges=None, baseline=None):
self.stale = True


class Lines(Patch):
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs a better name. BoundedSemiplane?

"""
*xy* is a numpy array with shape Nx2.

If *direction* is *True*, the patch is lower bounded by the polyline.
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there is a better name for direction? lowerbounded? lower? lower_bounded?

@@ -45,6 +45,30 @@
# different baseline images to prevent race conditions when pytest runs
# the tests with multiple threads.

@image_comparison(['fill_disjoint'], remove_text=False)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@image_comparison(['fill_disjoint'], remove_text=False)
@image_comparison(['fill_disjoint.png'], remove_text=False, style='mpl20')

fig, ax = plt.subplots()
plt.plot(xRng, [f1(x) for x in xRng], 'b-')
plt.plot(xRng, [f2(x) for x in xRng], 'r-')
# Uncomment below line to test other configs
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be removed. Or simply just add another test.

@antarapal235
Copy link
Author

Thank you so much @oscargus for these helpful suggestions. We just included them in our most recent commit.

@jklymak
Copy link
Member

jklymak commented Feb 2, 2023

This is failing all the tests. Can you include a description in the PR of what this does with code? Maybe also argue for the need for the extra complexity - it's not clear to me we should add all this. Finally, the new tests probably don't need to be in all the different file types?

@jklymak jklymak added status: needs clarification Issues that need more information to resolve. status: needs revision labels Feb 2, 2023
@jklymak jklymak marked this pull request as draft February 9, 2023 19:50
@jklymak
Copy link
Member

jklymak commented Feb 9, 2023

I'll move to draft, but feel free to move back when ready to move forward (if desired). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

[ENH]: fill_between invert?
5 participants