Skip to content

Commit 7c67cad

Browse files
committed
Highlight information about avoiding labels in legend
1 parent 972e95c commit 7c67cad

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lib/matplotlib/axes/_axes.py

+7-5
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

+3-2
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)