Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e62a5ac

Browse files
committed
Remove unnecessary explicit default loc='best' in legend()
1 parent c6ce3f6 commit e62a5ac

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
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, and the default loc='best'
13+
will try and 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
if not subplots:
2195-
ax.legend(ynamelist, loc='best')
2195+
ax.legend(ynamelist)
21962196

21972197
if xname=='date':
21982198
fig.autofmt_xdate()

0 commit comments

Comments
 (0)