1, line2, line3], ['label1', 'label2', 'label3']) **3. Explicitly listing the artists in the legend** This is similar to 2, but the labels are taken from the artists' label properties. Example:: line1, = ax.plot([1, 2, 3], label='label1') line2, = ax.plot([1, 2, 3], label='label2') ax.legend(handles=[line1, line2]) **4. Labeling existing plot elements** .. admonition:: Discouraged This call signature is discouraged, because the relation between plot elements and labels is only implicit by their order and can easily be mixed up. To make a legend for all artists on an Axes, call this function with an iterable of strings, one for each legend item. For example:: ax.plot([1, 2, 3]) ax.plot([5, 6, 7]) ax.legend(['First line', 'Second line']) Parameters ---------- handles : sequence of `.Artist`, optional A list of Artists (lines, patches) to be added to the legend. Use this together with *labels*, if you need full control on what is shown in the legend and the automatic mechanism described above is not sufficient. The length of handles and labels should be the same in this case. If they are not, they are truncated to the smaller length. labels : list of str, optional A list of labels to show next to the artists. Use this together with *handles*, if you need full control on what is shown in the legend and the automatic mechanism described above is not sufficient. Returns ------- `~matplotlib.legend.Legend` Other Parameters ---------------- %(_legend_kw_axes)s See Also -------- .Figure.legend Notes ----- Some artists are not supported by this function. See :doc:`/tutorials/intermediate/legend_guide` for details. Examples -------- .. plot:: gallery/text_labels_and_annotations/legend.py z-legend only accepts two non-keyword arguments)r@