You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
<divid="unreleased-message"> You are reading an old version of the documentation (v3.0.3). 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><h2><aclass="reference internal" href="#module-matplotlib.legend" title="matplotlib.legend"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">matplotlib.legend</span></code></a><aclass="headerlink" href="#module-matplotlib.legend" title="Permalink to this headline">¶</a></h2>
<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-meth 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 Legend class can be considered as a container of legend handles and
legend texts. Creation of corresponding legend handles from the plot elements
in the axes or figures (e.g., lines, patches, etc.) are specified by the
handler map, which defines the mapping between the plot elements and the
legend handlers to be used (the default legend handlers are defined in the
<aclass="reference internal" href="#module-matplotlib.legend_handler" title="matplotlib.legend_handler"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">legend_handler</span></code></a> module). Note that not all kinds of
artist are supported by the legend yet by default but it is possible to
extend the legend handler's capabilities to support arbitrary objects. See
the <aclass="reference internal" href="../tutorials/intermediate/legend_guide.html"><spanclass="doc">legend guide</span></a> for more
information.</p>
<dlclass="class">
<dtid="matplotlib.legend.DraggableLegend">
<emclass="property">class </em><codeclass="descclassname">matplotlib.legend.</code><codeclass="descname">DraggableLegend</code><spanclass="sig-paren">(</span><em>legend</em>, <em>use_blit=False</em>, <em>update='loc'</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>
<codeclass="descname">artist_picker</code><spanclass="sig-paren">(</span><em>legend</em>, <em>evt</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#DraggableLegend.artist_picker"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.DraggableLegend.artist_picker" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">finalize_offset</code><spanclass="sig-paren">(</span><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>
<dd><pclass="first last">A list of Artists (lines, patches) to be added to the legend.</p>
</dd>
<dt><strong>labels</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">sequence of strings</span></dt>
<dd><pclass="first last">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-delimiter">:</span><spanclass="classifier">int or string or pair of floats, default: <codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html#matplotlib-rcparams"><spanclass="pre">rcParams["legend.loc"]</span></a></code> ('best' for axes, 'upper right' for figures)</span></dt>
<dd><pclass="first">The location of the legend. Possible codes are:</p>
<p>Alternatively can be a 2-tuple giving <codeclass="docutils literal notranslate"><spanclass="pre">x,</span><spanclass="pre">y</span></code> of the lower-left
corner of the legend in axes coordinates (in which case
<codeclass="docutils literal notranslate"><spanclass="pre">bbox_to_anchor</span></code> will be ignored).</p>
<pclass="last">The 'best' option can be quite slow for plots with large amounts
of data. Your plotting speed may benefit from providing a specific
location.</p>
</dd>
<dt><strong>bbox_to_anchor</strong><spanclass="classifier-delimiter">:</span><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><pclass="first">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
<codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">bbox_transform</span></code>, 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>scatteryoffsets</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">iterable of floats</span></dt>
<dd><pclass="first last">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>. Default is <codeclass="docutils literal notranslate"><spanclass="pre">[0.375,</span><spanclass="pre">0.5,</span><spanclass="pre">0.3125]</span></code>.</p>
</dd>
<dt><strong>markerscale</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">None or int or float</span></dt>
<dd><pclass="first last">The relative size of legend markers compared with the originally
drawn ones.
Default is <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, which will take the value from
<dt><strong>fancybox</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">None or bool</span></dt>
<dd><pclass="first last">Control 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-class docutils literal notranslate"><spanclass="pre">FancyBboxPatch</span></code></a> which makes up the
legend's background.
Default is <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, which will take the value from
<dt><strong>framealpha</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">None or float</span></dt>
<dd><pclass="first last">Control the alpha transparency of the legend's background.
Default is <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, which will take the value from
<codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html#matplotlib-rcparams"><spanclass="pre">rcParams["legend.framealpha"]</span></a></code>. If shadow is activated and
<em>framealpha</em> is <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, the default value is ignored.</p>
</dd>
<dt><strong>facecolor</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">None or "inherit" or a color spec</span></dt>
<dd><pclass="first last">Control the legend's background color.
Default is <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, which will take the value from
<codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html#matplotlib-rcparams"><spanclass="pre">rcParams["legend.facecolor"]</span></a></code>. If <codeclass="docutils literal notranslate"><spanclass="pre">"inherit"</span></code>, it will take
<dt><strong>edgecolor</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">None or "inherit" or a color spec</span></dt>
<dd><pclass="first last">Control the legend's background patch edge color.
Default is <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, which will take the value from
<codeclass="docutils literal notranslate"><aclass="reference external" href="../tutorials/introductory/customizing.html#matplotlib-rcparams"><spanclass="pre">rcParams["legend.edgecolor"]</span></a></code> If <codeclass="docutils literal notranslate"><spanclass="pre">"inherit"</span></code>, it will take
<dd><pclass="first last">If <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">mode</span></code> is set to <codeclass="docutils literal notranslate"><spanclass="pre">"expand"</span></code> the legend will be horizontally
expanded to fill the axes area (or <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">bbox_to_anchor</span></code> if defines
<dd><pclass="first last">The transform for the bounding box (<codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">bbox_to_anchor</span></code>). 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-delimiter">:</span><spanclass="classifier">str or None</span></dt>
<dd><pclass="first last">The legend's title. Default is no title (<codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>).</p>
</dd>
<dt><strong>title_fontsize: str or None</strong></dt>
<dd><pclass="first last">The fontsize of the legend's title. Default is the default fontsize.</p>
</dd>
<dt><strong>borderpad</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">float or None</span></dt>
<dd><pclass="first last">The fractional whitespace inside the legend border.
Measured in font-size units.
Default is <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, which will take the value from
<dt><strong>handler_map</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">dict or None</span></dt>
<dd><pclass="first last">The custom dictionary mapping instances or types to a legend
handler. This <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">handler_map</span></code> 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-func 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. bbox_to_anchor can be an instance
of BboxBase(or its derivatives) 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-meth 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>event</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>
<p>Returns the truth value and a dictionary of artist specific details of
selection, such as which points are contained in the pick radius. See
individual artists for details.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.draggable">
<codeclass="descname">draggable</code><spanclass="sig-paren">(</span><em>state=None</em>, <em>use_blit=False</em>, <em>update='loc'</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.draggable"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.draggable" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the draggable state -- if state is</p>
<blockquote>
<div><ulclass="simple">
<li>None : toggle the current state</li>
<li>True : turn draggable on</li>
<li>False : turn draggable off</li>
</ul>
</div></blockquote>
<p>If draggable is on, you can drag the legend on the canvas with
the mouse. 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 is returned if
draggable is on.</p>
<p>The update parameter control which parameter of the legend changes
when dragged. If update is "loc", the <em>loc</em> parameter of the legend
is changed. If "bbox", the <em>bbox_to_anchor</em> parameter is changed.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.draw">
<codeclass="descname">draw</code><spanclass="sig-paren">(</span><em>renderer</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 everything that belongs to the legend.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.draw_frame">
<codeclass="descname">draw_frame</code><spanclass="sig-paren">(</span><em>b</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend.html#Legend.draw_frame"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend.Legend.draw_frame" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">get_bbox_to_anchor</code><spanclass="sig-paren">(</span><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="method">
<dtid="matplotlib.legend.Legend.get_children">
<codeclass="descname">get_children</code><spanclass="sig-paren">(</span><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>
<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="method">
<dtid="matplotlib.legend.Legend.get_draggable">
<codeclass="descname">get_draggable</code><spanclass="sig-paren">(</span><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="method">
<dtid="matplotlib.legend.Legend.get_frame">
<codeclass="descname">get_frame</code><spanclass="sig-paren">(</span><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> instances used to frame the legend.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.get_frame_on">
<codeclass="descname">get_frame_on</code><spanclass="sig-paren">(</span><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>legend_handler_map</em>, <em>orig_handle</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_hanler_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><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="method">
<dtid="matplotlib.legend.Legend.get_lines">
<codeclass="descname">get_lines</code><spanclass="sig-paren">(</span><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 a 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> instances in the legend.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.get_patches">
<codeclass="descname">get_patches</code><spanclass="sig-paren">(</span><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 a 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> instances in the legend.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.get_texts">
<codeclass="descname">get_texts</code><spanclass="sig-paren">(</span><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 a 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> instances in the legend.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.get_tightbbox">
<codeclass="descname">get_tightbbox</code><spanclass="sig-paren">(</span><em>renderer</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>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>`.BboxBase`</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">containing the bounding box in figure pixel co-ordinates.</span></dt>
<dd></dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.get_title">
<codeclass="descname">get_title</code><spanclass="sig-paren">(</span><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>renderer=None</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>
<codeclass="descname">set_bbox_to_anchor</code><spanclass="sig-paren">(</span><em>bbox</em>, <em>transform=None</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>
<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
<emclass="property">classmethod </em><codeclass="descname">set_default_handler_map</code><spanclass="sig-paren">(</span><em>handler_map</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="method">
<dtid="matplotlib.legend.Legend.set_draggable">
<codeclass="descname">set_draggable</code><spanclass="sig-paren">(</span><em>state</em>, <em>use_blit=False</em>, <em>update='loc'</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>
<dd><pclass="first">The legend parameter to be changed when dragged:</p>
<ulclass="last 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><strong>If *state* is ``True`` this returns the `~.DraggableLegend` helper</strong></dt>
<dd></dd>
<dt><strong>instance. Otherwise this returns ``None``.</strong></dt>
<dd></dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.legend.Legend.set_frame_on">
<codeclass="descname">set_frame_on</code><spanclass="sig-paren">(</span><em>b</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>title</em>, <em>prop=None</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>handler_map</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="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>
<p>It is strongly encouraged to have read the <aclass="reference internal" href="../tutorials/intermediate/legend_guide.html"><spanclass="doc">legend guide</span></a> before this documentation.</p>
<p>Legend handlers are expected to be a callable object with a following
<dd><pclass="first last">The box which has been created to hold this legend entry's
artists. Artists created in the <aclass="reference internal" href="#matplotlib.legend_handler.HandlerBase.legend_artist" title="matplotlib.legend_handler.HandlerBase.legend_artist"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">legend_artist</span></code></a> method must
be added to this handlebox inside this method.</p>
<codeclass="descname">update_prop</code><spanclass="sig-paren">(</span><em>legend_handle</em>, <em>orig_handle</em>, <em>legend</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend_handler.html#HandlerBase.update_prop"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend_handler.HandlerBase.update_prop" title="Permalink to this definition">¶</a></dt>
<dd><pclass="first last">Number of points to show in legend entry.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>Any other keyword arguments are given to <aclass="reference internal" href="#matplotlib.legend_handler.HandlerNpoints" title="matplotlib.legend_handler.HandlerNpoints"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">HandlerNpoints</span></code></a>.</p>
<dd><pclass="first last">Number of points to show in legend entry.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>Any other keyword arguments are given to <aclass="reference internal" href="#matplotlib.legend_handler.HandlerNpoints" title="matplotlib.legend_handler.HandlerNpoints"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">HandlerNpoints</span></code></a>.</p>
<codeclass="descname">get_numpoints</code><spanclass="sig-paren">(</span><em>legend</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend_handler.html#HandlerLineCollection.get_numpoints"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend_handler.HandlerLineCollection.get_numpoints" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.legend_handler.HandlerNpoints">
<emclass="property">class </em><codeclass="descclassname">matplotlib.legend_handler.</code><codeclass="descname">HandlerNpoints</code><spanclass="sig-paren">(</span><em>marker_pad=0.3</em>, <em>numpoints=None</em>, <em>**kw</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend_handler.html#HandlerNpoints"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend_handler.HandlerNpoints" title="Permalink to this definition">¶</a></dt>
<dd><p>A legend handler that shows <em>numpoints</em> points in the legend entry.</p>
<dd><pclass="first last">Number of points to show in legend entry.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>Any other keyword arguments are given to <aclass="reference internal" href="#matplotlib.legend_handler.HandlerBase" title="matplotlib.legend_handler.HandlerBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">HandlerBase</span></code></a>.</p>
<codeclass="descname">get_numpoints</code><spanclass="sig-paren">(</span><em>legend</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend_handler.html#HandlerNpoints.get_numpoints"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend_handler.HandlerNpoints.get_numpoints" title="Permalink to this definition">¶</a></dt>
<dd><pclass="first last">Number of points to show in legend entry.</p>
</dd>
<dt><strong>yoffsets</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">array of floats</span></dt>
<dd><pclass="first last">Length <em>numpoints</em> list of y offsets for each point in
legend entry.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>Any other keyword arguments are given to <aclass="reference internal" href="#matplotlib.legend_handler.HandlerNpoints" title="matplotlib.legend_handler.HandlerNpoints"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">HandlerNpoints</span></code></a>.</p>
<codeclass="descname">get_ydata</code><spanclass="sig-paren">(</span><em>legend</em>, <em>xdescent</em>, <em>ydescent</em>, <em>width</em>, <em>height</em>, <em>fontsize</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend_handler.html#HandlerNpointsYoffsets.get_ydata"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend_handler.HandlerNpointsYoffsets.get_ydata" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.legend_handler.HandlerPatch">
<emclass="property">class </em><codeclass="descclassname">matplotlib.legend_handler.</code><codeclass="descname">HandlerPatch</code><spanclass="sig-paren">(</span><em>patch_func=None</em>, <em>**kw</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend_handler.html#HandlerPatch"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend_handler.HandlerPatch" title="Permalink to this definition">¶</a></dt>
<pclass="last">Subsequently the created artist will have its <codeclass="docutils literal notranslate"><spanclass="pre">update_prop</span></code> method
called and the appropriate transform will be applied.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>Any other keyword arguments are given to <aclass="reference internal" href="#matplotlib.legend_handler.HandlerBase" title="matplotlib.legend_handler.HandlerBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">HandlerBase</span></code></a>.</p>
<emclass="property">class </em><codeclass="descclassname">matplotlib.legend_handler.</code><codeclass="descname">HandlerPathCollection</code><spanclass="sig-paren">(</span><em>yoffsets=None</em>, <em>sizes=None</em>, <em>**kw</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/legend_handler.html#HandlerPathCollection"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.legend_handler.HandlerPathCollection" title="Permalink to this definition">¶</a></dt>
<dd><p>Handler for <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">PathCollections</span></code>, which are used by <aclass="reference internal" href="_as_gen/matplotlib.axes.Axes.scatter.html#matplotlib.axes.Axes.scatter" title="matplotlib.axes.Axes.scatter"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">scatter</span></code></a>.</p>