@@ -1891,23 +1891,62 @@ def legend(self, *args, **kwargs):
18911891 """
18921892 Place a legend on the figure.
18931893
1894- To make a legend from existing artists on every axes::
1894+ Call signatures::
1895+
1896+ legend()
1897+ legend(labels)
1898+ legend(handles, labels)
1899+
1900+ The call signatures correspond to these three different ways to use
1901+ this method:
1902+
1903+ **1. Automatic detection of elements to be shown in the legend**
1904+
1905+ The elements to be added to the legend are automatically determined,
1906+ when you do not pass in any extra arguments.
1907+
1908+ In this case, the labels are taken from the artist. You can specify
1909+ them either at artist creation or by calling the
1910+ :meth:`~.Artist.set_label` method on the artist::
1911+
1912+ ax.plot([1, 2, 3], label='Inline label')
1913+ fig.legend()
1914+
1915+ or::
1916+
1917+ line, = ax.plot([1, 2, 3])
1918+ line.set_label('Label via method')
1919+ fig.legend()
18951920
1896- legend()
1921+ Specific lines can be excluded from the automatic legend element
1922+ selection by defining a label starting with an underscore.
1923+ This is default for all artists, so calling `.Figure.legend` without
1924+ any arguments and without setting the labels manually will result in
1925+ no legend being drawn.
18971926
1898- To make a legend for a list of lines and labels::
18991927
1900- legend(
1901- (line1, line2, line3),
1902- ('label1', 'label2', 'label3'),
1903- loc='upper right')
1928+ **2. Labeling existing plot elements**
19041929
1905- These can also be specified by keyword::
1930+ To make a legend for all artists on all Axes, call this function with
1931+ an iterable of strings, one for each legend item. For example::
19061932
1907- legend(
1908- handles=(line1, line2, line3),
1909- labels=('label1', 'label2', 'label3'),
1910- loc='upper right')
1933+ fig, (ax1, ax2) = plt.subplots(1, 2)
1934+ ax1.plot([1, 3, 5], color='blue')
1935+ ax2.plot([2, 4, 6], color='red')
1936+ fig.legend(['the blues', 'the reds'])
1937+
1938+ Note: This call signature is discouraged, because the relation between
1939+ plot elements and labels is only implicit by their order and can
1940+ easily be mixed up.
1941+
1942+
1943+ **3. Explicitly defining the elements in the legend**
1944+
1945+ For full control of which artists have a legend entry, it is possible
1946+ to pass an iterable of legend artists followed by an iterable of
1947+ legend labels respectively::
1948+
1949+ fig.legend([line1, line2, line3], ['label1', 'label2', 'label3'])
19111950
19121951 Parameters
19131952 ----------
@@ -1934,6 +1973,10 @@ def legend(self, *args, **kwargs):
19341973 ----------------
19351974 %(_legend_kw_doc)s
19361975
1976+ See Also
1977+ --------
1978+ .Axes.legend
1979+
19371980 Notes
19381981 -----
19391982 Some artists are not supported by this function. See
0 commit comments