<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/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>Module that allows plotting of string "category" data. i.e.
<codeclass="docutils literal notranslate"><spanclass="pre">plot(['d',</span><spanclass="pre">'f',</span><spanclass="pre">'a'],[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, provides a tick locator and formatter, and the
class:<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> that creates and stores the string-to-integer mapping.</p>
<dlclass="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>unit</em>, <em>axis</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>
<emclass="property">static </em><codeclass="descname">default_units</code><spanclass="sig-paren">(</span><em>data</em>, <em>axis</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>Sets and updates the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">axis</span></code> units.</p>
<dd><pclass="first last">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">
<dt><strong>class:~.UnitData~</strong></dt>
<dd><pclass="first last">object storing string to integer mapping</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.category.StrCategoryFormatter">
<emclass="property">class </em><codeclass="descclassname">matplotlib.category.</code><codeclass="descname">StrCategoryFormatter</code><spanclass="sig-paren">(</span><em>units_mapping</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>
<emclass="property">class </em><codeclass="descclassname">matplotlib.category.</code><codeclass="descname">StrCategoryLocator</code><spanclass="sig-paren">(</span><em>units_mapping</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>vmin</em>, <em>vmax</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>data=None</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: iterable</strong></dt>
<dd><pclass="first last">sequence of string values</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<dlclass="method">
<dtid="matplotlib.category.UnitData.update">
<codeclass="descname">update</code><spanclass="sig-paren">(</span><em>data</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>
<dd><p>Maps new values to integer identifiers.</p>