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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better str repr
  • Loading branch information
astromancer committed Mar 3, 2021
commit bd3f498d03d63a0244fe8f5133201c661b5e22f5
14 changes: 6 additions & 8 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,14 +1560,12 @@ class Annulus(Patch):

def __str__(self):
if self.a == self.b:
fmt = "Annulus(xy=(%s, %s), r=%s, width=%s, angle=%s)"
pars = (self.center[0], self.center[1],
self.a, self.width, self.angle)
r = str(self.a)
else:
fmt = "Annulus(xy=(%s, %s), r=(%s, %s), width=%s, angle=%s)"
pars = (self.center[0], self.center[1],
self.a, self.b, self.width, self.angle)
return fmt % pars
r = '(%s, %s)' % (self.a, self.b)

return "Annulus(xy=(%s, %s), r=%s, width=%s, angle=%s)" % \
(self.center[0], self.center[1], r, self.width, self.angle)

@docstring.dedent_interpd
def __init__(self, xy, r, width, angle=0.0, **kwargs):
Expand Down Expand Up @@ -1598,7 +1596,7 @@ def __init__(self, xy, r, width, angle=0.0, **kwargs):
self.a = self.b = float(r)
else:
raise ValueError(
'r parameter should be either float, or sequence of size 2')
'r parameter should be either float, or array_like of size 2')

if min(self.a, self.b) <= width:
raise ValueError(
Expand Down
0