X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,10 @@ def gca(self, **kwargs):
# continue and a new axes will be created
if key == ckey and isinstance(cax, projection_class):
return cax
else:
warnings.warn('Requested projection is different from '
'current axis projection, creating new axis '
'with requested projection.')

# no axes found, so create one which spans the figure
return self.add_subplot(1, 1, 1, **kwargs)
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,11 @@ def polar(*args, **kwargs):
strings, as in :func:`~matplotlib.pyplot.plot`.

"""
# If an axis 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)
ret = ax.plot(*args, **kwargs)
return ret
Expand Down
X Tutup