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

Commit0d0bde4

Browse files
committed
Remove unnecessary explicit default loc='best' in legend()
1 parentc6ce3f6 commit0d0bde4

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

‎examples/api/sankey_basics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
orientations=[-1,-1,-1],prior=0,connect=(0,0))
9292
diagrams=sankey.finish()
9393
diagrams[-1].patch.set_hatch('/')
94-
plt.legend(loc='best')
94+
plt.legend()
9595

9696
###############################################################################
9797
# Notice that only one connection is specified, but the systems form a

‎examples/recipes/transparent_legends.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
1010
ax.legend(loc='upper right')
1111
12-
Other times you don't know where your data is, and loc='best' will try
13-
and place the legend::
12+
Other times you don't know where your data is, andthe defaultloc='best'
13+
will tryand place the legend::
1414
15-
ax.legend(loc='best')
15+
ax.legend()
1616
1717
but still, your legend may overlap your data, and in these cases it's
1818
nice to make the legend frame transparent.
@@ -27,7 +27,7 @@
2727
ax.plot(np.random.rand(300),'s-',label='uniform distribution')
2828
ax.set_ylim(-3,3)
2929

30-
ax.legend(loc='best',fancybox=True,framealpha=0.5)
30+
ax.legend(fancybox=True,framealpha=0.5)
3131
ax.set_title('fancy, transparent legends')
3232

3333
plt.show()

‎lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2192,7 +2192,7 @@ def getname_val(identifier):
21922192
ax.set_xlabel('')
21932193

21942194
ifnotsubplots:
2195-
ax.legend(ynamelist,loc='best')
2195+
ax.legend(ynamelist)
21962196

21972197
ifxname=='date':
21982198
fig.autofmt_xdate()

‎lib/matplotlib/tests/test_legend.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def test_legend_auto1():
4040
x=np.arange(100)
4141
ax.plot(x,50-x,'o',label='y=1')
4242
ax.plot(x,x-50,'o',label='y=-1')
43-
ax.legend(loc='best')
43+
ax.legend()
4444

4545

4646
@image_comparison(baseline_images=['legend_auto2'],remove_text=True)
@@ -51,7 +51,7 @@ def test_legend_auto2():
5151
x=np.arange(100)
5252
b1=ax.bar(x,x,align='edge',color='m')
5353
b2=ax.bar(x,x[::-1],align='edge',color='g')
54-
ax.legend([b1[0],b2[0]], ['up','down'],loc='best')
54+
ax.legend([b1[0],b2[0]], ['up','down'])
5555

5656

5757
@image_comparison(baseline_images=['legend_auto3'])
@@ -64,7 +64,7 @@ def test_legend_auto3():
6464
ax.plot(x,y,'o-',label='line')
6565
ax.set_xlim(0.0,1.0)
6666
ax.set_ylim(0.0,1.0)
67-
ax.legend(loc='best')
67+
ax.legend()
6868

6969

7070
@image_comparison(baseline_images=['legend_various_labels'],remove_text=True)
@@ -75,7 +75,7 @@ def test_various_labels():
7575
ax.plot(np.arange(4),'o',label=1)
7676
ax.plot(np.linspace(4,4.1),'o',label='Développés')
7777
ax.plot(np.arange(4,1,-1),'o',label='__nolegend__')
78-
ax.legend(numpoints=1,loc='best')
78+
ax.legend(numpoints=1)
7979

8080

8181
@image_comparison(baseline_images=['legend_labels_first'],extensions=['png'],
@@ -87,7 +87,7 @@ def test_labels_first():
8787
ax.plot(np.arange(10),'-o',label=1)
8888
ax.plot(np.ones(10)*5,':x',label="x")
8989
ax.plot(np.arange(20,10,-1),'d',label="diamond")
90-
ax.legend(loc='best',markerfirst=False)
90+
ax.legend(markerfirst=False)
9191

9292

9393
@image_comparison(baseline_images=['legend_multiple_keys'],extensions=['png'],
@@ -371,7 +371,7 @@ def test_legend_stackplot():
371371
ax.stackplot(x,y1,y2,y3,labels=['y1','y2','y3'])
372372
ax.set_xlim((0,10))
373373
ax.set_ylim((0,70))
374-
ax.legend(loc='best')
374+
ax.legend()
375375

376376

377377
deftest_cross_figure_patch_legend():
@@ -424,7 +424,7 @@ def test_not_covering_scatter():
424424
forninrange(3):
425425
plt.scatter([n], [n],color=colors[n])
426426

427-
plt.legend(['foo','foo','foo'],loc='best')
427+
plt.legend(['foo','foo','foo'])
428428
plt.gca().set_xlim(-0.5,2.2)
429429
plt.gca().set_ylim(-0.5,2.2)
430430

@@ -439,7 +439,7 @@ def test_not_covering_scatter_transform():
439439

440440
plt.scatter([20], [10],transform=offset+plt.gca().transData)
441441

442-
plt.legend(['foo','bar'],loc='best')
442+
plt.legend(['foo','bar'])
443443

444444

445445
deftest_linecollection_scaled_dashes():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp