<divid="unreleased-message"> You are reading an old version of the documentation (v3.3.3). For the latest version see <ahref="https://matplotlib.org/stable/api/category_api.html">https://matplotlib.org/stable/api/category_api.html</a></div>
<spanid="matplotlib-category"></span><h1><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib.category</span></code><aclass="headerlink" href="#module-matplotlib.category" title="Permalink to this headline">¶</a></h1>
<p>Plotting of string "category" data: <codeclass="docutils literal notranslate"><spanclass="pre">plot(['d',</span><spanclass="pre">'f',</span><spanclass="pre">'a'],</span><spanclass="pre">[1,</span><spanclass="pre">2,</span><spanclass="pre">3])</span></code> will
plot three points with x-axis values of 'd', 'f', 'a'.</p>
<p>See <aclass="reference internal" href="../gallery/lines_bars_and_markers/categorical_variables.html"><spanclass="doc">Plotting categorical variables</span></a> for an
example.</p>
<p>The module uses Matplotlib's <aclass="reference internal" href="units_api.html#module-matplotlib.units" title="matplotlib.units"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">matplotlib.units</span></code></a> mechanism to convert from
strings to integers and provides a tick locator, a tick formatter, and the
<aclass="reference internal" href="#matplotlib.category.UnitData" title="matplotlib.category.UnitData"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">UnitData</span></code></a> class that creates and stores the string-to-integer mapping.</p>
<dlclass="py class">
<dtid="matplotlib.category.StrCategoryConverter">
<emclass="property">class </em><codeclass="descclassname">matplotlib.category.</code><codeclass="descname">StrCategoryConverter</code><aclass="reference internal" href="../_modules/matplotlib/category.html#StrCategoryConverter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.StrCategoryConverter" title="Permalink to this definition">¶</a></dt>
<emclass="property">static </em><codeclass="descname">axisinfo</code><spanclass="sig-paren">(</span><em><spanclass="n">unit</span></em>, <em><spanclass="n">axis</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/category.html#StrCategoryConverter.axisinfo"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.StrCategoryConverter.axisinfo" title="Permalink to this definition">¶</a></dt>
<dt><strong>unit</strong><spanclass="classifier"><aclass="reference internal" href="#matplotlib.category.UnitData" title="matplotlib.category.UnitData"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">UnitData</span></code></a></span></dt><dd><p>object string unit information for value</p>
</dd>
<dt><strong>axis</strong><spanclass="classifier"><aclass="reference internal" href="axis_api.html#matplotlib.axis.Axis" title="matplotlib.axis.Axis"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axis</span></code></a></span></dt><dd><p>axis for which information is being set</p>
</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="units_api.html#matplotlib.units.AxisInfo" title="matplotlib.units.AxisInfo"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">AxisInfo</span></code></a></dt><dd><p>Information to support default tick labeling</p>
<dt><strong>axis</strong><spanclass="classifier"><aclass="reference internal" href="axis_api.html#matplotlib.axis.Axis" title="matplotlib.axis.Axis"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axis</span></code></a></span></dt><dd><p>The axis on which the converted value is plotted.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last"><em>axis</em> is unused.</p>
</div>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<emclass="property">static </em><codeclass="descname">default_units</code><spanclass="sig-paren">(</span><em><spanclass="n">data</span></em>, <em><spanclass="n">axis</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/category.html#StrCategoryConverter.default_units"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.StrCategoryConverter.default_units" title="Permalink to this definition">¶</a></dt>
<dd><p>Set and update the <aclass="reference internal" href="axis_api.html#matplotlib.axis.Axis" title="matplotlib.axis.Axis"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axis</span></code></a> units.</p>
<dt><strong>data</strong><spanclass="classifier">str or iterable of str</span></dt><dd></dd>
<dt><strong>axis</strong><spanclass="classifier"><aclass="reference internal" href="axis_api.html#matplotlib.axis.Axis" title="matplotlib.axis.Axis"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axis</span></code></a></span></dt><dd><p>axis on which the data is plotted</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<emclass="property">class </em><codeclass="descclassname">matplotlib.category.</code><codeclass="descname">StrCategoryFormatter</code><spanclass="sig-paren">(</span><em><spanclass="n">units_mapping</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/category.html#StrCategoryFormatter"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.StrCategoryFormatter" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">format_ticks</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">values</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/category.html#StrCategoryFormatter.format_ticks"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.StrCategoryFormatter.format_ticks" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the tick labels for all the ticks at once.</p>
</dd></dl>
</dd></dl>
<dlclass="py class">
<dtid="matplotlib.category.StrCategoryLocator">
<emclass="property">class </em><codeclass="descclassname">matplotlib.category.</code><codeclass="descname">StrCategoryLocator</code><spanclass="sig-paren">(</span><em><spanclass="n">units_mapping</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/category.html#StrCategoryLocator"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.StrCategoryLocator" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">tick_values</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">vmin</span></em>, <em><spanclass="n">vmax</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/category.html#StrCategoryLocator.tick_values"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.StrCategoryLocator.tick_values" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the values of the located ticks given <strong>vmin</strong> and <strong>vmax</strong>.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<p>To get tick locations with the vmin and vmax values defined
automatically for the associated <codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">axis</span></code> simply call
<emclass="property">class </em><codeclass="descclassname">matplotlib.category.</code><codeclass="descname">UnitData</code><spanclass="sig-paren">(</span><em><spanclass="n">data</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/category.html#UnitData"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.UnitData" title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>data</strong><spanclass="classifier">iterable</span></dt><dd><p>sequence of string values</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<dlclass="py method">
<dtid="matplotlib.category.UnitData.update">
<codeclass="descname">update</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">data</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/category.html#UnitData.update"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.category.UnitData.update" title="Permalink to this definition">¶</a></dt>