8000 Update galleries/users_explain/axes/legend_guide.py · matplotlib/matplotlib@9bc95e4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9bc95e4

Browse files
story645timhoffm
andauthored
Update galleries/users_explain/axes/legend_guide.py
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent 8eca0ed commit 9bc95e4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

galleries/users_explain/axes/legend_guide.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@
7373
7474
If the handles are not directly accessible, for example when using some
7575
`Third-party packages <https://matplotlib.org/mpl-third-party/>`_, they can be accessed
76-
as follows::
76+
via `.Axes.get_legend_handles_and_labels` and fed into `.Axes.legend` explicitly.
77+
Here we use a dictionary to rename existing labels::
7778
7879
my_map = {'Line Up':'Up', 'Line Down':'Down'}
7980
8081
handles, labels = ax.get_legend_handles_labels()
8182
ax.legend(handles, [my_map[l] for l in labels])
8283
83-
Here we use a dictionary to ensure that we rename the correct entry.
84-
8584
8685
.. _proxy_legend_handles:
8786

0 commit comments

Comments
 (0)
0