-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix getting polar axes in plt.polar() #10674
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2283,12 +2283,15 @@ def polar(*args, **kwargs): | |
strings, as in :func:`~matplotlib.pyplot.plot`. | ||
|
||
""" | ||
# If an axis already exists, check if it has a polar projection | ||
# If an axes already exists, check if it has a polar projection | ||
if gcf().get_axes(): | ||
if not isinstance(gca(), PolarAxes): | ||
warnings.warn('Trying to create polar plot on an axis that does ' | ||
'not have a polar projection.') | ||
ax = gca(polar=True) | ||
ax = gca() | ||
else: | ||
ax = gcf().add_subplot(1, 1, 1, polar=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. umm, I'm not too up on the pyplot interface, but is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, but: If there are axes, use the gca(). If not, make a new one equivalent to subplot(111). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, but I don't get the point of this PR then. Why is this better than whats there now? Is the idea to let There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that the warning in #10660 is wrong. I need to rethink about the correct way to ultimately get rid of the axes collision behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, I'll close this then. |
||
|
||
ret = ax.plot(*args, **kwargs) | ||
return ret | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also added some newlines here to make the warning more readable.