<divid="unreleased-message"> You are reading an old version of the documentation (v3.3.4). For the latest version see <ahref="https://matplotlib.org/stable/api/legend_api.html">https://matplotlib.org/stable/api/legend_api.html</a></div>
<spanid="matplotlib-legend"></span><h1><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib.legend</span></code><aclass="headerlink" href="#module-matplotlib.legend" title="Permalink to this headline">¶</a></h1>
<p>The legend module defines the Legend class, which is responsible for
drawing legends associated with axes and/or figures.</p>
<divclass="admonition important">
<pclass="first admonition-title">Important</p>
<pclass="last">It is unlikely that you would ever create a Legend instance manually.
Most users would normally create a legend via the <aclass="reference internal" href="_as_gen/matplotlib.axes.Axes.legend.html#matplotlib.axes.Axes.legend" title="matplotlib.axes.Axes.legend"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">legend</span></code></a>
function. For more details on legends there is also a <aclass="reference internal" href="../tutorials/intermediate/legend_guide.html"><spanclass="doc">legend guide</span></a>.</p>
</div>
<p>The <aclass="reference internal" href="#matplotlib.legend.Legend" title="matplotlib.legend.Legend"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Legend</span></code></a> class is a container of legend handles and legend texts.</p>
<p>The legend handler map specifies how to create legend handles from artists
(lines, patches, etc.) in the axes or figures. Default legend handlers are
defined in the <aclass="reference internal" href="legend_handler_api.html#module-matplotlib.legend_handler" title="matplotlib.legend_handler"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">legend_handler</span></code></a> module. While not all artist
types are covered by the default legend handlers, custom legend handlers can be
defined to support arbitrary objects.</p>
<p>See the <aclass="reference internal" href="../tutorials/intermediate/legend_guide.html"><spanclass="doc">legend guide</span></a> for more
information.</p>
<dlclass="py class">
<dtid="matplotlib.legend.DraggableLegend">
<emclass="property">class </em><codeclass="descclassname">matplotlib.legend.</code><codeclass="descname">DraggableLegend</code><spanclass="sig-paren">(</span><em><spanclass="n">legend</span></em>, <em><spanclass="n">use_blit</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <em><spanclass="n">update</span><spanclass="o">=</span><spanclass="default_value">'loc'</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#DraggableLegend"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.DraggableLegend" title="Permalink to this definition">¶</a></dt>
<p>Wrapper around a <aclass="reference internal" href="#matplotlib.legend.Legend" title="matplotlib.legend.Legend"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Legend</span></code></a> to support mouse dragging.</p>
<dt><strong>update</strong><spanclass="classifier">{'loc', 'bbox'}, optional</span></dt><dd><p>If "loc", update the <em>loc</em> parameter of the legend upon finalizing.
If "bbox", update the <em>bbox_to_anchor</em> parameter.</p>
<codeclass="descname">finalize_offset</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#DraggableLegend.finalize_offset"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.DraggableLegend.finalize_offset" title="Permalink to this definition">¶</a></dt>
<dt><strong>parent</strong><spanclass="classifier"><aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a> or <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure</span></code></a></span></dt><dd><p>The artist that contains the legend.</p>
</dd>
<dt><strong>handles</strong><spanclass="classifier">list of <aclass="reference internal" href="artist_api.html#matplotlib.artist.Artist" title="matplotlib.artist.Artist"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Artist</span></code></a></span></dt><dd><p>A list of Artists (lines, patches) to be added to the legend.</p>
</dd>
<dt><strong>labels</strong><spanclass="classifier">list of str</span></dt><dd><p>A list of labels to show next to the artists. The length of handles
and labels should be the same. If they are not, they are truncated
to the smaller of both lengths.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Other Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>loc</strong><spanclass="classifier">str or pair of floats, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.loc#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.loc"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">'best'</span></code>) ('best' for axes, 'upper right' for figures)</span></dt><dd><p>The location of the legend.</p>
place the legend at the center of the corresponding edge of the
axes/figure.</p>
<p>The string <codeclass="docutils literal notranslate"><spanclass="pre">'center'</span></code> places the legend at the center of the axes/figure.</p>
<p>The string <codeclass="docutils literal notranslate"><spanclass="pre">'best'</span></code> places the legend at the location, among the nine
locations defined so far, with the minimum overlap with other drawn
artists. This option can be quite slow for plots with large amounts of
data; your plotting speed may benefit from providing a specific location.</p>
<p>The location can also be a 2-tuple giving the coordinates of the lower-left
corner of the legend in axes coordinates (in which case <em>bbox_to_anchor</em>
will be ignored).</p>
<p>For back-compatibility, <codeclass="docutils literal notranslate"><spanclass="pre">'center</span><spanclass="pre">right'</span></code> (but no other location) can also
be spelled <codeclass="docutils literal notranslate"><spanclass="pre">'right'</span></code>, and each "string" locations can also be given as a
<dt><strong>bbox_to_anchor</strong><spanclass="classifier"><aclass="reference internal" href="transformations.html#matplotlib.transforms.BboxBase" title="matplotlib.transforms.BboxBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">BboxBase</span></code></a>, 2-tuple, or 4-tuple of floats</span></dt><dd><p>Box that is used to position the legend in conjunction with <em>loc</em>.
Defaults to <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">axes.bbox</span></code> (if called as a method to <aclass="reference internal" href="_as_gen/matplotlib.axes.Axes.legend.html#matplotlib.axes.Axes.legend" title="matplotlib.axes.Axes.legend"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes.legend</span></code></a>) or
<p>Bbox coordinates are interpreted in the coordinate system given by
<em>bbox_transform</em>, with the default transform
Axes or Figure coordinates, depending on which <codeclass="docutils literal notranslate"><spanclass="pre">legend</span></code> is called.</p>
<p>If a 4-tuple or <aclass="reference internal" href="transformations.html#matplotlib.transforms.BboxBase" title="matplotlib.transforms.BboxBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">BboxBase</span></code></a> is given, then it specifies the bbox
<codeclass="docutils literal notranslate"><spanclass="pre">(x,</span><spanclass="pre">y,</span><spanclass="pre">width,</span><spanclass="pre">height)</span></code> that the legend is placed in.
To put the legend in the best location in the bottom right
<p>A 2-tuple <codeclass="docutils literal notranslate"><spanclass="pre">(x,</span><spanclass="pre">y)</span></code> places the corner of the legend specified by <em>loc</em> at
x, y. For example, to put the legend's upper right-hand corner in the
center of the axes (or figure) the following keywords can be used:</p>
<dt><strong>ncol</strong><spanclass="classifier">int, default: 1</span></dt><dd><p>The number of columns that the legend has.</p>
</dd>
<dt><strong>prop</strong><spanclass="classifier">None or <aclass="reference internal" href="font_manager_api.html#matplotlib.font_manager.FontProperties" title="matplotlib.font_manager.FontProperties"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.font_manager.FontProperties</span></code></a> or dict</span></dt><dd><p>The font properties of the legend. If None (default), the current
<aclass="reference internal" href="matplotlib_configuration_api.html#matplotlib.rcParams" title="matplotlib.rcParams"><codeclass="xref py py-data docutils literal notranslate"><spanclass="pre">matplotlib.rcParams</span></code></a> will be used.</p>
</dd>
<dt><strong>fontsize</strong><spanclass="classifier">int or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}</span></dt><dd><p>The font size of the legend. If the value is numeric the size will be the
absolute font size in points. String values are relative to the current
default font size. This argument is only used if <em>prop</em> is not specified.</p>
</dd>
<dt><strong>labelcolor</strong><spanclass="classifier">str or list</span></dt><dd><p>Sets the color of the text in the legend. Can be a valid color string
(for example, 'red'), or a list of color strings. The labelcolor can
also be made to match the color of the line or marker using 'linecolor',
'markerfacecolor' (or 'mfc'), or 'markeredgecolor' (or 'mec').</p>
</dd>
<dt><strong>numpoints</strong><spanclass="classifier">int, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.numpoints#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.numpoints"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">1</span></code>)</span></dt><dd><p>The number of marker points in the legend when creating a legend
entry for a <aclass="reference internal" href="_as_gen/matplotlib.lines.Line2D.html#matplotlib.lines.Line2D" title="matplotlib.lines.Line2D"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Line2D</span></code></a> (line).</p>
</dd>
<dt><strong>scatterpoints</strong><spanclass="classifier">int, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.scatterpoints#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.scatterpoints"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">1</span></code>)</span></dt><dd><p>The number of marker points in the legend when creating
a legend entry for a <aclass="reference internal" href="collections_api.html#matplotlib.collections.PathCollection" title="matplotlib.collections.PathCollection"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">PathCollection</span></code></a> (scatter plot).</p>
</dd>
<dt><strong>scatteryoffsets</strong><spanclass="classifier">iterable of floats, default: <codeclass="docutils literal notranslate"><spanclass="pre">[0.375,</span><spanclass="pre">0.5,</span><spanclass="pre">0.3125]</span></code></span></dt><dd><p>The vertical offset (relative to the font size) for the markers
created for a scatter plot legend entry. 0.0 is at the base the
legend text, and 1.0 is at the top. To draw all markers at the
same height, set to <codeclass="docutils literal notranslate"><spanclass="pre">[0.5]</span></code>.</p>
</dd>
<dt><strong>markerscale</strong><spanclass="classifier">float, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.markerscale#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.markerscale"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">1.0</span></code>)</span></dt><dd><p>The relative size of legend markers compared with the originally
drawn ones.</p>
</dd>
<dt><strong>markerfirst</strong><spanclass="classifier">bool, default: True</span></dt><dd><p>If <em>True</em>, legend marker is placed to the left of the legend label.
If <em>False</em>, legend marker is placed to the right of the legend label.</p>
</dd>
<dt><strong>frameon</strong><spanclass="classifier">bool, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.frameon#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.frameon"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">True</span></code>)</span></dt><dd><p>Whether the legend should be drawn on a patch (frame).</p>
</dd>
<dt><strong>fancybox</strong><spanclass="classifier">bool, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.fancybox#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.fancybox"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">True</span></code>)</span></dt><dd><p>Whether round edges should be enabled around the <aclass="reference internal" href="_as_gen/matplotlib.patches.FancyBboxPatch.html#matplotlib.patches.FancyBboxPatch" title="matplotlib.patches.FancyBboxPatch"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">FancyBboxPatch</span></code></a> which
makes up the legend's background.</p>
</dd>
<dt><strong>shadow</strong><spanclass="classifier">bool, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.shadow#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.shadow"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">False</span></code>)</span></dt><dd><p>Whether to draw a shadow behind the legend.</p>
</dd>
<dt><strong>framealpha</strong><spanclass="classifier">float, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.framealpha#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.framealpha"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">0.8</span></code>)</span></dt><dd><p>The alpha transparency of the legend's background.
If <em>shadow</em> is activated and <em>framealpha</em> is <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, the default value is
If <codeclass="docutils literal notranslate"><spanclass="pre">"inherit"</span></code>, use take <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=axes.edgecolor#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["axes.edgecolor"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">'black'</span></code>).</p>
</dd>
<dt><strong>mode</strong><spanclass="classifier">{"expand", None}</span></dt><dd><p>If <em>mode</em> is set to <codeclass="docutils literal notranslate"><spanclass="pre">"expand"</span></code> the legend will be horizontally
expanded to fill the axes area (or <em>bbox_to_anchor</em> if defines
the legend's size).</p>
</dd>
<dt><strong>bbox_transform</strong><spanclass="classifier">None or <aclass="reference internal" href="transformations.html#matplotlib.transforms.Transform" title="matplotlib.transforms.Transform"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.transforms.Transform</span></code></a></span></dt><dd><p>The transform for the bounding box (<em>bbox_to_anchor</em>). For a value
of <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code> (default) the Axes'
<codeclass="xref py py-data docutils literal notranslate"><spanclass="pre">transAxes</span></code> transform will be used.</p>
</dd>
<dt><strong>title</strong><spanclass="classifier">str or None</span></dt><dd><p>The legend's title. Default is no title (<codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>).</p>
</dd>
<dt><strong>title_fontsize</strong><spanclass="classifier">int or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.title_fontsize#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.title_fontsize"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>)</span></dt><dd><p>The font size of the legend's title.</p>
</dd>
<dt><strong>borderpad</strong><spanclass="classifier">float, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.borderpad#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.borderpad"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">0.4</span></code>)</span></dt><dd><p>The fractional whitespace inside the legend border, in font-size units.</p>
</dd>
<dt><strong>labelspacing</strong><spanclass="classifier">float, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.labelspacing#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.labelspacing"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">0.5</span></code>)</span></dt><dd><p>The vertical space between the legend entries, in font-size units.</p>
</dd>
<dt><strong>handlelength</strong><spanclass="classifier">float, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.handlelength#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.handlelength"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">2.0</span></code>)</span></dt><dd><p>The length of the legend handles, in font-size units.</p>
</dd>
<dt><strong>handletextpad</strong><spanclass="classifier">float, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.handletextpad#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.handletextpad"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">0.8</span></code>)</span></dt><dd><p>The pad between the legend handle and text, in font-size units.</p>
</dd>
<dt><strong>borderaxespad</strong><spanclass="classifier">float, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.borderaxespad#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.borderaxespad"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">0.5</span></code>)</span></dt><dd><p>The pad between the axes and legend border, in font-size units.</p>
</dd>
<dt><strong>columnspacing</strong><spanclass="classifier">float, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html?highlight=legend.columnspacing#a-sample-matplotlibrc-file"><spanclass="pre">rcParams["legend.columnspacing"]</span></a></code> (default: <codeclass="docutils literal notranslate"><spanclass="pre">2.0</span></code>)</span></dt><dd><p>The spacing between columns, in font-size units.</p>
</dd>
<dt><strong>handler_map</strong><spanclass="classifier">dict or None</span></dt><dd><p>The custom dictionary mapping instances or types to a legend
handler. This <em>handler_map</em> updates the default handler map
found at <aclass="reference internal" href="#matplotlib.legend.Legend.get_legend_handler_map" title="matplotlib.legend.Legend.get_legend_handler_map"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.legend.Legend.get_legend_handler_map</span></code></a>.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>Users can specify any arbitrary location for the legend using the
<em>bbox_to_anchor</em> keyword argument. <em>bbox_to_anchor</em> can be a
<aclass="reference internal" href="transformations.html#matplotlib.transforms.BboxBase" title="matplotlib.transforms.BboxBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">BboxBase</span></code></a> (or derived therefrom) or a tuple of 2 or 4 floats.
See <aclass="reference internal" href="#matplotlib.legend.Legend.set_bbox_to_anchor" title="matplotlib.legend.Legend.set_bbox_to_anchor"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">set_bbox_to_anchor</span></code></a> for more detail.</p>
<p>The legend location can be specified by setting <em>loc</em> with a tuple of
2 floats, which is interpreted as the lower-left corner of the legend
<codeclass="descname">contains</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">event</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.contains"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Test whether the artist contains the mouse event.</p>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>contains</strong><spanclass="classifier">bool</span></dt><dd><p>Whether any values are within the radius.</p>
</dd>
<dt><strong>details</strong><spanclass="classifier">dict</span></dt><dd><p>An artist-specific dictionary of details of the event context,
such as which points are contained in the pick radius. See the
individual Artist subclasses for details.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.draw">
<codeclass="descname">draw</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">renderer</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.draw"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.draw" title="Permalink to this definition">¶</a></dt>
<dd><p>Draw the Artist (and its children) using the given renderer.</p>
<p>This has no effect if the artist is not visible (<aclass="reference internal" href="_as_gen/matplotlib.artist.Artist.get_visible.html#matplotlib.artist.Artist.get_visible" title="matplotlib.artist.Artist.get_visible"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Artist.get_visible</span></code></a>
<p>This method is overridden in the Artist subclasses.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.draw_frame">
<codeclass="descname">draw_frame</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">b</span></em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.legend.Legend.draw_frame" title="Permalink to this definition">¶</a></dt>
<dd><p>Set whether the legend box patch is drawn.</p>
<codeclass="descname">get_bbox_to_anchor</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_bbox_to_anchor"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_bbox_to_anchor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the bbox that the legend will be anchored to.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.get_children">
<codeclass="descname">get_children</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_children"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_children" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of the child <aclass="reference internal" href="artist_api.html#matplotlib.artist.Artist" title="matplotlib.artist.Artist"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Artist</span></code></a>s of this <aclass="reference internal" href="artist_api.html#matplotlib.artist.Artist" title="matplotlib.artist.Artist"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Artist</span></code></a>.</p>
<emclass="property">classmethod </em><codeclass="descname">get_default_handler_map</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_default_handler_map"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_default_handler_map" title="Permalink to this definition">¶</a></dt>
<dd><p>A class method that returns the default handler map.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.get_draggable">
<codeclass="descname">get_draggable</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_draggable"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_draggable" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <codeclass="docutils literal notranslate"><spanclass="pre">True</span></code> if the legend is draggable, <codeclass="docutils literal notranslate"><spanclass="pre">False</span></code> otherwise.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.get_frame">
<codeclass="descname">get_frame</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_frame"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_frame" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <aclass="reference internal" href="_as_gen/matplotlib.patches.Rectangle.html#matplotlib.patches.Rectangle" title="matplotlib.patches.Rectangle"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Rectangle</span></code></a> used to frame the legend.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.get_frame_on">
<codeclass="descname">get_frame_on</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_frame_on"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_frame_on" title="Permalink to this definition">¶</a></dt>
<dd><p>Get whether the legend box patch is drawn.</p>
<emclass="property">static </em><codeclass="descname">get_legend_handler</code><spanclass="sig-paren">(</span><em><spanclass="n">legend_handler_map</span></em>, <em><spanclass="n">orig_handle</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_legend_handler"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_legend_handler" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a legend handler from <em>legend_handler_map</em> that
corresponds to <em>orig_handler</em>.</p>
<p><em>legend_handler_map</em> should be a dictionary object (that is
returned by the get_legend_handler_map method).</p>
<p>It first checks if the <em>orig_handle</em> itself is a key in the
<em>legend_handler_map</em> and return the associated value.
Otherwise, it checks for each of the classes in its
method-resolution-order. If no matching key is found, it
<codeclass="descname">get_legend_handler_map</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_legend_handler_map"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_legend_handler_map" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the handler map.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.get_lines">
<codeclass="descname">get_lines</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_lines"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of <aclass="reference internal" href="_as_gen/matplotlib.lines.Line2D.html#matplotlib.lines.Line2D" title="matplotlib.lines.Line2D"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Line2D</span></code></a>s in the legend.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.get_patches">
<codeclass="descname">get_patches</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_patches"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_patches" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of <aclass="reference internal" href="_as_gen/matplotlib.patches.Patch.html#matplotlib.patches.Patch" title="matplotlib.patches.Patch"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Patch</span></code></a>s in the legend.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.get_texts">
<codeclass="descname">get_texts</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_texts"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_texts" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of <aclass="reference internal" href="text_api.html#matplotlib.text.Text" title="matplotlib.text.Text"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Text</span></code></a>s in the legend.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.get_tightbbox">
<codeclass="descname">get_tightbbox</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">renderer</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_tightbbox"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_tightbbox" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <aclass="reference internal" href="#matplotlib.legend.Legend.get_window_extent" title="matplotlib.legend.Legend.get_window_extent"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Legend.get_window_extent</span></code></a>, but uses the box for the legend.</p>
<dt><strong>renderer</strong><spanclass="classifier"><aclass="reference internal" href="backend_bases_api.html#matplotlib.backend_bases.RendererBase" title="matplotlib.backend_bases.RendererBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">RendererBase</span></code></a> subclass</span></dt><dd><p>renderer that will be used to draw the figures (i.e.
<codeclass="descname">get_title</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_title"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_title" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <aclass="reference internal" href="text_api.html#matplotlib.text.Text" title="matplotlib.text.Text"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Text</span></code></a> instance for the legend title.</p>
<codeclass="descname">get_window_extent</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">renderer</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.get_window_extent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.get_window_extent" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the axes bounding box in display space.</p>
<p>The bounding box' width and height are nonnegative.</p>
<p>Subclasses should override for inclusion in the bounding box
"tight" calculation. Default is to return an empty bounding
box at 0, 0.</p>
<p>Be careful when using this function, the results will not update
if the artist window extent of the artist changes. The extent
can change due to any changes in the transform stack, such as
changing the axes limits, the figure size, or the canvas used
(as is done when saving a figure). This can lead to unexpected
behavior where interactive figures will look fine on the screen,
<codeclass="descname">set_bbox_to_anchor</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">bbox</span></em>, <em><spanclass="n">transform</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.set_bbox_to_anchor"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.set_bbox_to_anchor" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the bbox that the legend will be anchored to.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>bbox</strong><spanclass="classifier"><aclass="reference internal" href="transformations.html#matplotlib.transforms.BboxBase" title="matplotlib.transforms.BboxBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">BboxBase</span></code></a> or tuple</span></dt><dd><p>The bounding box can be specified in the following ways:</p>
<li>A tuple of <codeclass="docutils literal notranslate"><spanclass="pre">(left,</span><spanclass="pre">bottom,</span><spanclass="pre">width,</span><spanclass="pre">height)</span></code> in the given
transform (normalized axes coordinate if None)</li>
<li>A tuple of <codeclass="docutils literal notranslate"><spanclass="pre">(left,</span><spanclass="pre">bottom)</span></code> where the width and height will be
assumed to be zero.</li>
<li><em>None</em>, to remove the bbox anchoring, and use the parent bbox.</li>
</ul>
</dd>
<dt><strong>transform</strong><spanclass="classifier"><aclass="reference internal" href="transformations.html#matplotlib.transforms.Transform" title="matplotlib.transforms.Transform"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Transform</span></code></a>, optional</span></dt><dd><p>A transform to apply to the bounding box. If not specified, this
will use a transform to the bounding box of the parent.</p>
<emclass="property">classmethod </em><codeclass="descname">set_default_handler_map</code><spanclass="sig-paren">(</span><em><spanclass="n">handler_map</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.set_default_handler_map"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.set_default_handler_map" title="Permalink to this definition">¶</a></dt>
<dd><p>A class method to set the default handler map.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.set_draggable">
<codeclass="descname">set_draggable</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">state</span></em>, <em><spanclass="n">use_blit</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <em><spanclass="n">update</span><spanclass="o">=</span><spanclass="default_value">'loc'</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.set_draggable"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.set_draggable" title="Permalink to this definition">¶</a></dt>
<dd><p>Enable or disable mouse dragging support of the legend.</p>
<dt><strong>update</strong><spanclass="classifier">{'loc', 'bbox'}, optional</span></dt><dd><p>The legend parameter to be changed when dragged:</p>
<ulclass="simple">
<li>'loc': update the <em>loc</em> parameter of the legend</li>
<li>'bbox': update the <em>bbox_to_anchor</em> parameter of the legend</li>
</ul>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><aclass="reference internal" href="#matplotlib.legend.DraggableLegend" title="matplotlib.legend.DraggableLegend"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">DraggableLegend</span></code></a> or <em>None</em></dt><dd><p>If <em>state</em> is <codeclass="docutils literal notranslate"><spanclass="pre">True</span></code> this returns the <aclass="reference internal" href="#matplotlib.legend.DraggableLegend" title="matplotlib.legend.DraggableLegend"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">DraggableLegend</span></code></a> helper
instance. Otherwise this returns <em>None</em>.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.legend.Legend.set_frame_on">
<codeclass="descname">set_frame_on</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">b</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.set_frame_on"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.set_frame_on" title="Permalink to this definition">¶</a></dt>
<dd><p>Set whether the legend box patch is drawn.</p>
<codeclass="descname">set_title</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">title</span></em>, <em><spanclass="n">prop</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.set_title"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.set_title" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the legend title. Fontproperties can be optionally set
<emclass="property">classmethod </em><codeclass="descname">update_default_handler_map</code><spanclass="sig-paren">(</span><em><spanclass="n">handler_map</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.update_default_handler_map"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.update_default_handler_map" title="Permalink to this definition">¶</a></dt>
<dd><p>A class method to update the default handler map.</p>
</dd></dl>
<dlclass="py attribute">
<dtid="matplotlib.legend.Legend.zorder">
<codeclass="descname">zorder</code><emclass="property"> = 5</em><aclass="headerlink" href="#matplotlib.legend.Legend.zorder" title="Permalink to this definition">¶</a></dt>