<divid="unreleased-message"> You are reading an old version of the documentation (v3.2.0). For the latest version see <ahref="https://matplotlib.org/stable/api/units_api.html">https://matplotlib.org/stable/api/units_api.html</a></div>
<spanid="matplotlib-units"></span><h1><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib.units</span></code><aclass="headerlink" href="#module-matplotlib.units" title="Permalink to this headline">¶</a></h1>
<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
<dt><strong>default_limits</strong><spanclass="classifier">optional</span></dt><dd><p>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="exception">
<dtid="matplotlib.units.ConversionError">
<emclass="property">exception </em><codeclass="descclassname">matplotlib.units.</code><codeclass="descname">ConversionError</code><aclass="reference internal" href="../_modules/matplotlib/units.html#ConversionError"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.ConversionError" title="Permalink to this definition">¶</a></dt>
<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> for the axis with the specified units.</p>
<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.DecimalConverter">
<emclass="property">class </em><codeclass="descclassname">matplotlib.units.</code><codeclass="descname">DecimalConverter</code><aclass="reference internal" href="../_modules/matplotlib/units.html#DecimalConverter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.DecimalConverter" 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#DecimalConverter.axisinfo"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.DecimalConverter.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> for the axis with the specified units.</p>
<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#DecimalConverter.default_units"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.units.DecimalConverter.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>
</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>
<codeclass="descname">get_converter</code><spanclass="sig-paren">(</span><em>self</em>, <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 interface instance for <em>x</em>, or None.</p>