8000 Improve getting of polar axes in plt.polar() · matplotlib/matplotlib@671100f · GitHub
[go: up one dir, main page]

Skip to content

Commit 671100f

Browse files
committed
Improve getting of polar axes in plt.polar()
1 parent 3208322 commit 671100f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/pyplot.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,12 +2283,15 @@ def polar(*args, **kwargs):
22832283
strings, as in :func:`~matplotlib.pyplot.plot`.
22842284
22852285
"""
2286-
# If an axis already exists, check if it has a polar projection
2286+
# If an axes already exists, check if it has a polar projection
22872287
if gcf().get_axes():
22882288
if not isinstance(gca(), PolarAxes):
22892289
warnings.warn('Trying to create polar plot on an axis that does '
22902290
'not have a polar projection.')
2291-
ax = gca(polar=True)
2291+
ax = gca()
2292+
else:
2293+
ax = gcf().add_subplot(1, 1, 1, polar=True)
2294+
22922295
ret = ax.plot(*args, **kwargs)
22932296
return ret
22942297

0 commit comments

Comments
 (0)
0