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

Appearance settings

Commit 6dee4f5

Browse filesBrowse files
authored
Merge pull request #23673 from oscargus/legenddocs
DOC: Highlight information about avoiding labels in legend
2 parents b54b335 + 7c67cad commit 6dee4f5
Copy full SHA for 6dee4f5

File tree

Expand file treeCollapse file tree

2 files changed

+10
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-7
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,13 @@ def legend(self, *args, **kwargs):
215215
line.set_label('Label via method')
216216
ax.legend()
217217
218-
Specific lines can be excluded from the automatic legend element
219-
selection by defining a label starting with an underscore.
220-
This is default for all artists, so calling `.Axes.legend` without
221-
any arguments and without setting the labels manually will result in
222-
no legend being drawn.
218+
.. note::
219+
Specific artists can be excluded from the automatic legend element
220+
selection by using a label starting with an underscore, "_".
221+
A string starting with an underscore is the default label for all
222+
artists, so calling `.Axes.legend` without any arguments and
223+
without setting the labels manually will result in no legend being
224+
drawn.
223225
224226
225227
**2. Explicitly listing the artists and labels in the legend**

‎tutorials/intermediate/legend_guide.py

Copy file name to clipboardExpand all lines: tutorials/intermediate/legend_guide.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@
4747
not all artists can be added to a legend, at which point a "proxy" will have
4848
to be created (see :ref:`proxy_legend_handles` for further details).
4949
50-
Those artists with an empty string as label or with a label starting with
51-
"_" will be ignored.
50+
.. note::
51+
Artists with an empty string as label or with a label starting with an
52+
underscore, "_", will be ignored.
5253
5354
For full control of what is being added to the legend, it is common to pass
5455
the appropriate handles directly to :func:`legend`::

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.