<divid="unreleased-message"> You are reading an old version of the documentation (v2.2.4). For the latest version see <ahref="https://matplotlib.org/stable/api/units_api.html">https://matplotlib.org/stable/api/units_api.html</a></div>
<h1>units<aclass="headerlink" href="#units" title="Permalink to this headline">¶</a></h1>
<divclass="section" id="module-matplotlib.units">
<spanid="matplotlib-units"></span><h2><aclass="reference internal" href="#module-matplotlib.units" title="matplotlib.units"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">matplotlib.units</span></code></a><aclass="headerlink" href="#module-matplotlib.units" title="Permalink to this headline">¶</a></h2>
<p>The classes here provide support for using custom classes with
Matplotlib, e.g., those that do not expose the array interface but know
how to convert themselves to arrays. It also supports classes with
units and units conversion. Use cases include converters for custom
objects, e.g., a list of datetime objects, as well as for objects that
are unit aware. We don't assume any particular units implementation;
rather a units implementation must provide the register with the Registry
converter dictionary and a <aclass="reference internal" href="#matplotlib.units.ConversionInterface" title="matplotlib.units.ConversionInterface"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ConversionInterface</span></code></a>. For example,
here is a complete implementation which supports plotting with native
<dd><pclass="first last">The default min and max limits of the axis if no data has
been plotted.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>If any of the above are <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>, the axis will simply use the
default value.</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.units.ConversionInterface">
<emclass="property">class </em><codeclass="descclassname">matplotlib.units.</code><codeclass="descname">ConversionInterface</code><aclass="reference internal" href="../_modules/matplotlib/units.html#ConversionInterface"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.ConversionInterface" title="Permalink to this definition">¶</a></dt>
<emclass="property">static </em><codeclass="descname">axisinfo</code><spanclass="sig-paren">(</span><em>unit</em>, <em>axis</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/units.html#ConversionInterface.axisinfo"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.ConversionInterface.axisinfo" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">AxisInfo</span></code> instance for the axis with the
<emclass="property">static </em><codeclass="descname">default_units</code><spanclass="sig-paren">(</span><em>x</em>, <em>axis</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/units.html#ConversionInterface.default_units"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.ConversionInterface.default_units" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the default unit for <em>x</em> or <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code> for the given axis.</p>
<emclass="property">static </em><codeclass="descname">is_numlike</code><spanclass="sig-paren">(</span><em>x</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/units.html#ConversionInterface.is_numlike"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.ConversionInterface.is_numlike" title="Permalink to this definition">¶</a></dt>
<dd><p>The Matplotlib datalim, autoscaling, locators etc work with
scalars which are the units converted to floats given the
current unit. The converter may be passed these floats, or
arrays of them, even when units are set.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.units.Registry">
<emclass="property">class </em><codeclass="descclassname">matplotlib.units.</code><codeclass="descname">Registry</code><aclass="reference internal" href="../_modules/matplotlib/units.html#Registry"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.Registry" title="Permalink to this definition">¶</a></dt>
<p>A register that maps types to conversion interfaces.</p>
<dlclass="method">
<dtid="matplotlib.units.Registry.get_converter">
<codeclass="descname">get_converter</code><spanclass="sig-paren">(</span><em>x</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/units.html#Registry.get_converter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.Registry.get_converter" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the converter for data that has the same type as <em>x</em>. If no
converters are registered for <em>x</em>, returns <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>.</p>