Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6510bc4

Browse files
authored
Merge pull request#21139 from meeseeksmachine/auto-backport-of-pr-21131-on-v3.4.x
2 parents79a38ec +691ac9d commit6510bc4

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

‎lib/matplotlib/pyplot.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,14 +2478,12 @@ def polar(*args, **kwargs):
24782478
# If an axis already exists, check if it has a polar projection
24792479
ifgcf().get_axes():
24802480
ax=gca()
2481-
ifisinstance(ax,PolarAxes):
2482-
returnax
2483-
else:
2481+
ifnotisinstance(ax,PolarAxes):
24842482
_api.warn_external('Trying to create polar plot on an Axes '
24852483
'that does not have a polar projection.')
2486-
ax=axes(projection="polar")
2487-
ret=ax.plot(*args,**kwargs)
2488-
returnret
2484+
else:
2485+
ax=axes(projection="polar")
2486+
returnax.plot(*args,**kwargs)
24892487

24902488

24912489
# If rcParams['backend_fallback'] is true, and an interactive backend is

‎lib/matplotlib/tests/test_pyplot.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,13 @@ def test_subplot_change_projection():
310310
assertax_next.name==proj
311311
assertaxisnotax_next
312312
ax=ax_next
313+
314+
315+
deftest_polar_second_call():
316+
# the first call creates the axes with polar projection
317+
ln1,=plt.polar(0.,1.,'ro')
318+
assertisinstance(ln1,mpl.lines.Line2D)
319+
# the second call should reuse the existing axes
320+
ln2,=plt.polar(1.57,.5,'bo')
321+
assertisinstance(ln2,mpl.lines.Line2D)
322+
assertln1.axesisln2.axes

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp