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

Commit11b8e4e

Browse files
authored
Merge pull request#30079 from rcomer/legend-iter
FIX: cast legend handles to list
2 parents1c881a3 +b41edd0 commit11b8e4e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

‎lib/matplotlib/legend.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ def __init__(
459459
labels= [*reversed(labels)]
460460
handles= [*reversed(handles)]
461461

462+
handles=list(handles)
462463
iflen(handles)<2:
463464
ncols=1
464465
self._ncols=ncolsifncols!=1elsencol

‎lib/matplotlib/tests/test_legend.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,18 @@ def test_legend_ordereddict():
4242
loc='center left',bbox_to_anchor=(1,.5))
4343

4444

45+
deftest_legend_generator():
46+
# smoketest that generator inputs work
47+
fig,ax=plt.subplots()
48+
ax.plot([0,1])
49+
ax.plot([0,2])
50+
51+
handles= (lineforlineinax.get_lines())
52+
labels= (labelforlabelin ['spam','eggs'])
53+
54+
ax.legend(handles,labels,loc='upper left')
55+
56+
4557
@image_comparison(['legend_auto1.png'],remove_text=True)
4658
deftest_legend_auto1():
4759
"""Test automatic legend placement"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp