8000 Add an Annulus patch class by astromancer · Pull Request #9888 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Add an Annulus patch class #9888

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 18 commits into from
Apr 15, 2021
Merged

Conversation

astromancer
Copy link
Contributor
@astromancer astromancer commented Nov 30, 2017

PR Summary

Adds an the Annulus class to the patches library. This can be used to create annular ellipses or circle patches. I include a small example below that demos the usage.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way
import matplotlib.pyplot as plt
from matplotlib.patches import Annulus

fig, ax = plt.subplots()
cir = Annulus((0.5, 0.5), 0.2, 0.05, fc='g')        # circular annulus
ell = Annulus((0.5, 0.5), (0.5, 0.3), 0.1, 45,      # elliptical
              fc='m', ec='b', alpha=0.5, hatch='xxx') 
ax.add_patch(cir)
ax.add_patch(ell)
ax.set_aspect('equal')

mpl annulus

@WeatherGod
Copy link
Member
WeatherGod commented Nov 30, 2017 via email

@tacaswell tacaswell added this to the v2.2 milestone Nov 30, 2017
@QuLogic
Copy link
Member
QuLogic commented Dec 1, 2017

Something similar is supported by Wedge, except it's not general enough to support ellipses. Some of these things can maybe be modified to derive from each other.

@astromancer
Copy link
Contributor Author
astromancer commented Dec 1, 2017

Yes, the Annulus code is basically cobbled together from snippets from Wedge and Arc classes. I'll check if I can extend either one of those in a sensible way to produce the desired effect.

What might also be quite nice is to have a generic class that can transform any Patch object to an annular patch. So one can do something like Annulus(Rectangle)(*args, **kws) to get a rectangular annulus patch.

@jklymak
Copy link
Member
jklymak commented Jul 16, 2020

@astromancer This still looks viable if you have time to address @eric-wieser comments and do a rebase. Please (politely!) ping if you don't get reviews so we remember this. We have many open PRs so things get buried.

@astromancer
Copy link
Contributor Author

@jklymak Thanks for the ping. It's been on my mind to get back to this for some time now. Will have a look at folding in your comments in the next week or so.

@jklymak jklymak marked this pull request as draft September 10, 2020 15:08
@eric-wieser
Copy link
Contributor

Something appears to have gone catastrophically wrong with your merge commit

@astromancer
Copy link
Contributor Author

Yeah my bad, any idea how to fix this?

@eric-wieser
Copy link
Contributor
eric-wieser commented Mar 3, 2021

Well, your merge commit 9e0739e has one bad parent and one ok looking one.

Edit: whoops, links were bad.

Merge diff: master...9e0739e

One parent: master...9f12372

The other parent: master...b8e8976

@eric-wieser
Copy link
Contributor

My guess is that the right thing to do is:

git reset --hard 9f12372b3982f30e742d4ae98d099ab125d2d75f
git push -f

@astromancer astromancer marked this pull request as ready for review March 5, 2021 07:29
@astromancer
Copy link
Contributor Author

So this is green across the board now, but needs one more review. @QuLogic @WeatherGod I'm looking into your suggestions of inheriting from Wedge or Arc (or creating some common base for all of these), but I think the amount of work required for that would merit a separate PR. Let me know what you think. ✌️

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.

  1. The doc style has changed since the original PR. Needed changes are listed below.
  2. For consistency, we need get/set methods and the setters should self.stale = True.

astromancer and others added 3 commits March 12, 2021 09:52
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
Copy link
Member
@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

test coverage of the setters and getters could be enhanced....

@astromancer
Copy link
Contributor Author

Copy that, will add some tests to bump the coverage 🧪️

@jklymak
Copy link
Member
jklymak commented Mar 24, 2021

Please keep pinging us @astromancer I don't see any fundamental reason this can't go in for the next major release, unless anyone else is opposed....

Copy link
Member
@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

This seems fine. I am confused why codecov is confused. Are we sure get_path is always called on draw? I suppose it must be...

.transform(verts)

def _recompute_path(self):
# circular arc
Copy link
Member

Choose a reason for hiding this comment

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

This looks great. However, do we understand why codecov is confused by this?

Copy link
Member

Choose a reason for hiding this comment

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

I have given up trying to understand codecov. Above it warns on a line that's part of a docstring.

@timhoffm timhoffm merged commit ad33280 into matplotlib:master Apr 15, 2021
@timhoffm
Copy link
Member
timhoffm commented Apr 15, 2021

Thanks @astromancer! This took a long way, but it's in finally. 🎉

@QuLogic
Copy link
Member
QuLogic commented Apr 15, 2021

I don't now why docs didn't build before you merged, but it broke from this.

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.

8 participants
0