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.3.2). For the latest version see <ahref="https://matplotlib.org/stable/api/cbook_api.html">https://matplotlib.org/stable/api/cbook_api.html</a></div>
<spanid="matplotlib-cbook"></span><h1><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib.cbook</span></code><aclass="headerlink" href="#module-matplotlib.cbook" title="Permalink to this headline">¶</a></h1>
<p>A collection of utility functions and classes. Originally, many
(but not all) were from the Python Cookbook -- hence the name cbook.</p>
<p>This module is safe to import from anywhere within Matplotlib;
it imports Matplotlib only at runtime.</p>
<dlclass="py class">
<dtid="matplotlib.cbook.CallbackRegistry">
<emclass="property">class </em><codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">CallbackRegistry</code><spanclass="sig-paren">(</span><em>exception_handler=<function _exception_printer></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#CallbackRegistry"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.CallbackRegistry" title="Permalink to this definition">¶</a></dt>
<spanclass="gp">>>> </span><spanclass="n">callbacks</span><spanclass="o">.</span><spanclass="n">process</span><spanclass="p">(</span><spanclass="s1">'be merry'</span><spanclass="p">,</span><spanclass="mi">456</span><spanclass="p">)</span><spanclass="c1"># nothing will be called</span>
<spanclass="gp">>>> </span><spanclass="n">callbacks</span><spanclass="o">.</span><spanclass="n">process</span><spanclass="p">(</span><spanclass="s1">'eat'</span><spanclass="p">,</span><spanclass="mi">456</span><spanclass="p">)</span><spanclass="c1"># nothing will be called</span>
</pre></div>
</div>
<p>In practice, one should always disconnect all callbacks when they are
no longer needed to avoid dangling references (and thus memory leaks).
However, real code in Matplotlib rarely does so, and due to its design,
it is rather difficult to place this kind of code. To get around this,
and prevent this class of memory leaks, we instead store weak references
to bound methods only, so when the destination object needs to die, the
<p>If not None this function will be called with any <aclass="reference external" href="https://docs.python.org/3/library/exceptions.html#Exception" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Exception</span></code></a>
subclass raised by the callbacks in <aclass="reference internal" href="#matplotlib.cbook.CallbackRegistry.process" title="matplotlib.cbook.CallbackRegistry.process"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">CallbackRegistry.process</span></code></a>.
The handler may either consume the exception or re-raise.</p>
<codeclass="descname">connect</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">s</span></em>, <em><spanclass="n">func</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#CallbackRegistry.connect"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.CallbackRegistry.connect" title="Permalink to this definition">¶</a></dt>
<dd><p>Register <em>func</em> to be called when signal <em>s</em> is generated.</p>
<codeclass="descname">disconnect</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">cid</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#CallbackRegistry.disconnect"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.CallbackRegistry.disconnect" title="Permalink to this definition">¶</a></dt>
<dd><p>Disconnect the callback registered with callback id <em>cid</em>.</p>
<codeclass="descname">process</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">s</span></em>, <em><spanclass="o">*</span><spanclass="n">args</span></em>, <em><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#CallbackRegistry.process"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.CallbackRegistry.process" title="Permalink to this definition">¶</a></dt>
<dd><p>Process signal <em>s</em>.</p>
<p>All of the functions registered to receive callbacks on <em>s</em> will be
called with <codeclass="docutils literal notranslate"><spanclass="pre">*args</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">**kwargs</span></code>.</p>
</dd></dl>
</dd></dl>
<dlclass="py class">
<dtid="matplotlib.cbook.Grouper">
<emclass="property">class </em><codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">Grouper</code><spanclass="sig-paren">(</span><em><spanclass="n">init</span><spanclass="o">=</span><spanclass="default_value">()</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Grouper"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Grouper" title="Permalink to this definition">¶</a></dt>
<p>Objects can be joined using <aclass="reference internal" href="#matplotlib.cbook.Grouper.join" title="matplotlib.cbook.Grouper.join"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">join()</span></code></a>, tested for connectedness
using <aclass="reference internal" href="#matplotlib.cbook.Grouper.joined" title="matplotlib.cbook.Grouper.joined"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">joined()</span></code></a>, and all disjoint sets can be retrieved by
using the object as an iterator.</p>
<p>The objects being joined must be hashable and weak-referenceable.</p>
<codeclass="descname">clean</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Grouper.clean"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Grouper.clean" title="Permalink to this definition">¶</a></dt>
<dd><p>Clean dead weak references from the dictionary.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Grouper.get_siblings">
<codeclass="descname">get_siblings</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">a</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Grouper.get_siblings"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Grouper.get_siblings" title="Permalink to this definition">¶</a></dt>
<dd><p>Return all of the items joined with <em>a</em>, including itself.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Grouper.join">
<codeclass="descname">join</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">a</span></em>, <em><spanclass="o">*</span><spanclass="n">args</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Grouper.join"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Grouper.join" title="Permalink to this definition">¶</a></dt>
<dd><p>Join given arguments into the same set. Accepts one or more arguments.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Grouper.joined">
<codeclass="descname">joined</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">a</span></em>, <em><spanclass="n">b</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Grouper.joined"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Grouper.joined" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether <em>a</em> and <em>b</em> are members of the same set.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Grouper.remove">
<codeclass="descname">remove</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">a</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Grouper.remove"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Grouper.remove" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="py exception">
<dtid="matplotlib.cbook.IgnoredKeywordWarning">
<emclass="property">exception </em><codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">IgnoredKeywordWarning</code><spanclass="sig-paren">(</span><em><spanclass="o">*</span><spanclass="n">args</span></em>, <em><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#IgnoredKeywordWarning"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.IgnoredKeywordWarning" title="Permalink to this definition">¶</a></dt>
<p>[<em>Deprecated</em>] A class for issuing warnings about keyword arguments that will be ignored
by Matplotlib.</p>
<pclass="rubric">Notes</p>
<divclass="deprecated">
<p><spanclass="versionmodified deprecated">Deprecated since version 3.3.</span></p>
</div>
</dd></dl>
<dlclass="py class">
<dtid="matplotlib.cbook.Stack">
<emclass="property">class </em><codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">Stack</code><spanclass="sig-paren">(</span><em><spanclass="n">default</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">back</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack.back"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack.back" title="Permalink to this definition">¶</a></dt>
<dd><p>Move the position back and return the current element.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Stack.bubble">
<codeclass="descname">bubble</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">o</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack.bubble"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack.bubble" title="Permalink to this definition">¶</a></dt>
<dd><p>Raise all references of <em>o</em> to the top of the stack, and return it.</p>
<trclass="field-odd field"><thclass="field-name">Raises:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>ValueError</dt><dd><p>If <em>o</em> is not in the stack.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Stack.clear">
<codeclass="descname">clear</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack.clear"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Empty the stack.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Stack.empty">
<codeclass="descname">empty</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack.empty"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack.empty" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the stack is empty.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Stack.forward">
<codeclass="descname">forward</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack.forward"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack.forward" title="Permalink to this definition">¶</a></dt>
<dd><p>Move the position forward and return the current element.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Stack.home">
<codeclass="descname">home</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack.home"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack.home" title="Permalink to this definition">¶</a></dt>
<dd><p>Push the first element onto the top of the stack.</p>
<p>The first element is returned.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Stack.push">
<codeclass="descname">push</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">o</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack.push"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack.push" title="Permalink to this definition">¶</a></dt>
<dd><p>Push <em>o</em> to the stack at current position. Discard all later elements.</p>
<p><em>o</em> is returned.</p>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.cbook.Stack.remove">
<codeclass="descname">remove</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">o</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#Stack.remove"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.Stack.remove" title="Permalink to this definition">¶</a></dt>
<dt><strong>X</strong><spanclass="classifier">array-like</span></dt><dd><p>Data that will be represented in the boxplots. Should have 2 or
fewer dimensions.</p>
</dd>
<dt><strong>whis</strong><spanclass="classifier">float or (float, float), default: 1.5</span></dt><dd><p>The position of the whiskers.</p>
<p>If a float, the lower whisker is at the lowest datum above
<codeclass="docutils literal notranslate"><spanclass="pre">Q1</span><spanclass="pre">-</span><spanclass="pre">whis*(Q3-Q1)</span></code>, and the upper whisker at the highest datum below
<codeclass="docutils literal notranslate"><spanclass="pre">Q3</span><spanclass="pre">+</span><spanclass="pre">whis*(Q3-Q1)</span></code>, where Q1 and Q3 are the first and third
quartiles. The default value of <codeclass="docutils literal notranslate"><spanclass="pre">whis</span><spanclass="pre">=</span><spanclass="pre">1.5</span></code> corresponds to Tukey's
original definition of boxplots.</p>
<p>If a pair of floats, they indicate the percentiles at which to draw the
whiskers (e.g., (5, 95)). In particular, setting this to (0, 100)
results in whiskers covering the whole range of the data. "range" is
a deprecated synonym for (0, 100).</p>
<p>In the edge case where <codeclass="docutils literal notranslate"><spanclass="pre">Q1</span><spanclass="pre">==</span><spanclass="pre">Q3</span></code>, <em>whis</em> is automatically set to
(0, 100) (cover the whole range of the data) if <em>autorange</em> is True.</p>
<p>Beyond the whiskers, data are considered outliers and are plotted as
individual points.</p>
</dd>
<dt><strong>bootstrap</strong><spanclass="classifier">int, optional</span></dt><dd><p>Number of times the confidence intervals around the median
should be bootstrapped (percentile method).</p>
</dd>
<dt><strong>labels</strong><spanclass="classifier">array-like, optional</span></dt><dd><p>Labels for each dataset. Length must be compatible with
dimensions of <em>X</em>.</p>
</dd>
<dt><strong>autorange</strong><spanclass="classifier">bool, optional (False)</span></dt><dd><p>When <aclass="reference external" href="https://docs.python.org/3/library/constants.html#True" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">True</span></code></a> and the data are distributed such that the 25th and 75th
percentiles are equal, <codeclass="docutils literal notranslate"><spanclass="pre">whis</span></code> is set to (0, 100) such that the
whisker ends are at the minimum and maximum of the data.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>list of dict</dt><dd><p>A list of dictionaries containing the results for each column
of data. Keys of each dictionary are the following:</p>
<tableborder="1" class="docutils align-default">
<colgroup>
<colwidth="19%" />
<colwidth="81%" />
</colgroup>
<theadvalign="bottom">
<trclass="row-odd"><thclass="head">Key</th>
<thclass="head">Value Description</th>
</tr>
</thead>
<tbodyvalign="top">
<trclass="row-even"><td>label</td>
<td>tick label for the boxplot</td>
</tr>
<trclass="row-odd"><td>mean</td>
<td>arithmetic mean value</td>
</tr>
<trclass="row-even"><td>med</td>
<td>50th percentile</td>
</tr>
<trclass="row-odd"><td>q1</td>
<td>first quartile (25th percentile)</td>
</tr>
<trclass="row-even"><td>q3</td>
<td>third quartile (75th percentile)</td>
</tr>
<trclass="row-odd"><td>cilo</td>
<td>lower notch around the median</td>
</tr>
<trclass="row-even"><td>cihi</td>
<td>upper notch around the median</td>
</tr>
<trclass="row-odd"><td>whislo</td>
<td>end of the lower whisker</td>
</tr>
<trclass="row-even"><td>whishi</td>
<td>end of the upper whisker</td>
</tr>
<trclass="row-odd"><td>fliers</td>
<td>outliers</td>
</tr>
</tbody>
</table>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>Non-bootstrapping approach to confidence interval uses Gaussian-based
McGill, R., Tukey, J.W., and Larsen, W.A. (1978) "Variations of
Boxplots", The American Statistician, 32:12-16.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.contiguous_regions">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">contiguous_regions</code><spanclass="sig-paren">(</span><em><spanclass="n">mask</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#contiguous_regions"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.contiguous_regions" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of (ind0, ind1) such that <codeclass="docutils literal notranslate"><spanclass="pre">mask[ind0:ind1].all()</span></code> is
True and we cover all such regions.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.delete_masked_points">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">delete_masked_points</code><spanclass="sig-paren">(</span><em><spanclass="o">*</span><spanclass="n">args</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#delete_masked_points"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.delete_masked_points" title="Permalink to this definition">¶</a></dt>
<dd><p>Find all masked and/or non-finite points in a set of arguments,
and return the arguments with only the unmasked points remaining.</p>
<p>Arguments can be in any of 5 categories:</p>
<olclass="arabic simple">
<li>1-D masked arrays</li>
<li>1-D ndarrays</li>
<li>ndarrays with more than one dimension</li>
<li>other non-string iterables</li>
<li>anything else</li>
</ol>
<p>The first argument must be in one of the first four categories;
any argument with a length differing from that of the first
argument (and hence anything in category 5) then will be
passed through unchanged.</p>
<p>Masks are obtained from all arguments of the correct length
in categories 1, 2, and 4; a point is bad if masked in a masked
array or if it is a nan or inf. No attempt is made to
extract a mask from categories 2, 3, and 4 if <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.isfinite.html#numpy.isfinite" title="(in NumPy v1.19)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">numpy.isfinite</span></code></a>
does not yield a Boolean array.</p>
<p>All input arguments that are not passed unchanged are returned
as ndarrays after removing the points or rows corresponding to
masks in any of the arguments.</p>
<p>A vastly simpler version of this function was originally
written as a helper for Axes.scatter().</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.file_requires_unicode">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">file_requires_unicode</code><spanclass="sig-paren">(</span><em><spanclass="n">x</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#file_requires_unicode"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.file_requires_unicode" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the given writable file-like object requires Unicode to be
written to it.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.flatten">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">flatten</code><spanclass="sig-paren">(</span><em>seq</em>, <em>scalarp=<function is_scalar_or_string at 0x7f2814b5b280></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#flatten"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.flatten" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a generator of flattened nested containers.</p>
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">get_realpath_and_stat</code><spanclass="sig-paren">(</span><em><spanclass="n">path</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#get_realpath_and_stat"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.get_realpath_and_stat" title="Permalink to this definition">¶</a></dt>
<dd><p>[<em>Deprecated</em>]</p>
<pclass="rubric">Notes</p>
<divclass="deprecated">
<p><spanclass="versionmodified deprecated">Deprecated since version 3.3: </span></p>
</div>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.get_sample_data">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">get_sample_data</code><spanclass="sig-paren">(</span><em><spanclass="n">fname</span></em>, <em><spanclass="n">asfileobj</span><spanclass="o">=</span><spanclass="default_value">True</span></em>, <em><spanclass="o">*</span></em>, <em><spanclass="n">np_load</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#get_sample_data"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.get_sample_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a sample data file. <em>fname</em> is a path relative to the
<codeclass="file docutils literal notranslate"><spanclass="pre">mpl-data/sample_data</span></code> directory. If <em>asfileobj</em> is <aclass="reference external" href="https://docs.python.org/3/library/constants.html#True" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">True</span></code></a>
return a file object, otherwise just a file path.</p>
<p>Sample data files are stored in the 'mpl-data/sample_data' directory within
the Matplotlib package.</p>
<p>If the filename ends in .gz, the file is implicitly ungzipped. If the
filename ends with .npy or .npz, <em>asfileobj</em> is True, and <em>np_load</em> is
True, the file is loaded with <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.load.html#numpy.load" title="(in NumPy v1.19)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">numpy.load</span></code></a>. <em>np_load</em> currently defaults
to False but will default to True in a future release.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.index_of">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">index_of</code><spanclass="sig-paren">(</span><em><spanclass="n">y</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#index_of"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.index_of" title="Permalink to this definition">¶</a></dt>
<dd><p>A helper function to create reasonable x values for the given <em>y</em>.</p>
<p>This is used for plotting (x, y) if x values are not explicitly given.</p>
<p>First try <codeclass="docutils literal notranslate"><spanclass="pre">y.index</span></code> (assuming <em>y</em> is a <aclass="reference external" href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html#pandas.Series" title="(in pandas v1.1.2)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">pandas.Series</span></code></a>), if that
fails, use <codeclass="docutils literal notranslate"><spanclass="pre">range(len(y))</span></code>.</p>
<p>This will be extended in the future to deal with more types of
<dt><strong>y</strong><spanclass="classifier">float or array-like</span></dt><dd></dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>x, y</strong><spanclass="classifier">ndarray</span></dt><dd><p>The x and y values to plot.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.is_math_text">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">is_math_text</code><spanclass="sig-paren">(</span><em><spanclass="n">s</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#is_math_text"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.is_math_text" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the string <em>s</em> contains math expressions.</p>
<p>This is done by checking whether <em>s</em> contains an even number of
non-escaped dollar signs.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.is_scalar_or_string">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">is_scalar_or_string</code><spanclass="sig-paren">(</span><em><spanclass="n">val</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#is_scalar_or_string"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.is_scalar_or_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether the given object is a scalar or string like.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.is_writable_file_like">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">is_writable_file_like</code><spanclass="sig-paren">(</span><em><spanclass="n">obj</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#is_writable_file_like"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.is_writable_file_like" title="Permalink to this definition">¶</a></dt>
<dd><p>Return whether <em>obj</em> looks like a file object with a <em>write</em> method.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.local_over_kwdict">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">local_over_kwdict</code><spanclass="sig-paren">(</span><em><spanclass="n">local_var</span></em>, <em><spanclass="n">kwargs</span></em>, <em><spanclass="o">*</span><spanclass="n">keys</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#local_over_kwdict"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.local_over_kwdict" title="Permalink to this definition">¶</a></dt>
<dd><p>[<em>Deprecated</em>] Enforces the priority of a local variable over potentially conflicting
argument(s) from a kwargs dict. The following possible output values are
<dt>any object</dt><dd><p>Either local_var or one of kwargs[key] for key in keys.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-odd field"><thclass="field-name">Raises:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>IgnoredKeywordWarning</dt><dd><p>For each key in keys that is removed from kwargs but not used as
the output value.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<divclass="deprecated">
<p><spanclass="versionmodified deprecated">Deprecated since version 3.3.</span></p>
</div>
</dd></dl>
<dlclass="py class">
<dtid="matplotlib.cbook.maxdict">
<emclass="property">class </em><codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">maxdict</code><spanclass="sig-paren">(</span><em><spanclass="n">maxsize</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#maxdict"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.maxdict" title="Permalink to this definition">¶</a></dt>
<dt><strong>kw</strong><spanclass="classifier">dict</span></dt><dd><p>A dict of keyword arguments.</p>
</dd>
<dt><strong>alias_mapping</strong><spanclass="classifier">dict or Artist subclass or Artist instance, optional</span></dt><dd><p>A mapping between a canonical name to a list of
aliases, in order of precedence from lowest to highest.</p>
<p>If the canonical value is not in the list it is assumed to have
the highest priority.</p>
<p>If an Artist subclass or instance is passed, use its properties alias
mapping.</p>
</dd>
<dt><strong>required</strong><spanclass="classifier">list of str, optional</span></dt><dd><p>A list of keys that must be in <em>kws</em>. This parameter is deprecated.</p>
</dd>
<dt><strong>forbidden</strong><spanclass="classifier">list of str, optional</span></dt><dd><p>A list of keys which may not be in <em>kw</em>. This parameter is deprecated.</p>
</dd>
<dt><strong>allowed</strong><spanclass="classifier">list of str, optional</span></dt><dd><p>A list of allowed fields. If this not None, then raise if
<em>kw</em> contains any keys not in the union of <em>required</em>
and <em>allowed</em>. To allow only the required fields pass in
an empty tuple <codeclass="docutils literal notranslate"><spanclass="pre">allowed=()</span></code>. This parameter is deprecated.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Raises:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>TypeError</dt><dd><p>To match what python raises if invalid args/kwargs are passed to
a callable.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.open_file_cm">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">open_file_cm</code><spanclass="sig-paren">(</span><em><spanclass="n">path_or_file</span></em>, <em><spanclass="n">mode</span><spanclass="o">=</span><spanclass="default_value">'r'</span></em>, <em><spanclass="n">encoding</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#open_file_cm"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.open_file_cm" title="Permalink to this definition">¶</a></dt>
<dd><p>Pass through file objects and context-manage path-likes.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.print_cycles">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">print_cycles</code><spanclass="sig-paren">(</span><em>objects</em>, <em>outstream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'></em>, <em>show_progress=False</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#print_cycles"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.print_cycles" title="Permalink to this definition">¶</a></dt>
<dd><p>Print loops of cyclic references in the given <em>objects</em>.</p>
<p>It is often useful to pass in <codeclass="docutils literal notranslate"><spanclass="pre">gc.garbage</span></code> to find the cycles that are
preventing some objects from being garbage collected.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>objects</strong></dt><dd><p>A list of objects to find cycles in.</p>
</dd>
<dt><strong>outstream</strong></dt><dd><p>The stream for output.</p>
</dd>
<dt><strong>show_progress</strong><spanclass="classifier">bool</span></dt><dd><p>If True, print the number of objects reached as they are found.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.pts_to_midstep">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">pts_to_midstep</code><spanclass="sig-paren">(</span><em><spanclass="n">x</span></em>, <em><spanclass="o">*</span><spanclass="n">args</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#pts_to_midstep"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.pts_to_midstep" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert continuous line to mid-steps.</p>
<p>Given a set of <codeclass="docutils literal notranslate"><spanclass="pre">N</span></code> points convert to <codeclass="docutils literal notranslate"><spanclass="pre">2N</span></code> points which when connected
linearly give a step function which changes values at the middle of the
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>array</dt><dd><p>The x and y values converted to steps in the same order as the input;
can be unpacked as <codeclass="docutils literal notranslate"><spanclass="pre">x_out,</span><spanclass="pre">y1_out,</span><spanclass="pre">...,</span><spanclass="pre">yp_out</span></code>. If the input is
length <codeclass="docutils literal notranslate"><spanclass="pre">N</span></code>, each of these arrays will be length <codeclass="docutils literal notranslate"><spanclass="pre">2N</span></code>.</p>
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">pts_to_poststep</code><spanclass="sig-paren">(</span><em><spanclass="n">x</span></em>, <em><spanclass="o">*</span><spanclass="n">args</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#pts_to_poststep"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.pts_to_poststep" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert continuous line to post-steps.</p>
<p>Given a set of <codeclass="docutils literal notranslate"><spanclass="pre">N</span></code> points convert to <codeclass="docutils literal notranslate"><spanclass="pre">2N</span><spanclass="pre">+</span><spanclass="pre">1</span></code> points, which when
connected linearly give a step function which changes values at the end of
<dt><strong>x</strong><spanclass="classifier">array</span></dt><dd><p>The x location of the steps. May be empty.</p>
</dd>
<dt><strong>y1, ..., yp</strong><spanclass="classifier">array</span></dt><dd><p>y arrays to be turned into steps; all must be the same length as <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code>.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>array</dt><dd><p>The x and y values converted to steps in the same order as the input;
can be unpacked as <codeclass="docutils literal notranslate"><spanclass="pre">x_out,</span><spanclass="pre">y1_out,</span><spanclass="pre">...,</span><spanclass="pre">yp_out</span></code>. If the input is
length <codeclass="docutils literal notranslate"><spanclass="pre">N</span></code>, each of these arrays will be length <codeclass="docutils literal notranslate"><spanclass="pre">2N</span><spanclass="pre">+</span><spanclass="pre">1</span></code>. For
<codeclass="docutils literal notranslate"><spanclass="pre">N=0</span></code>, the length will be 0.</p>
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">pts_to_prestep</code><spanclass="sig-paren">(</span><em><spanclass="n">x</span></em>, <em><spanclass="o">*</span><spanclass="n">args</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#pts_to_prestep"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.pts_to_prestep" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert continuous line to pre-steps.</p>
<p>Given a set of <codeclass="docutils literal notranslate"><spanclass="pre">N</span></code> points, convert to <codeclass="docutils literal notranslate"><spanclass="pre">2N</span><spanclass="pre">-</span><spanclass="pre">1</span></code> points, which when
connected linearly give a step function which changes values at the
<dt><strong>x</strong><spanclass="classifier">array</span></dt><dd><p>The x location of the steps. May be empty.</p>
</dd>
<dt><strong>y1, ..., yp</strong><spanclass="classifier">array</span></dt><dd><p>y arrays to be turned into steps; all must be the same length as <codeclass="docutils literal notranslate"><spanclass="pre">x</span></code>.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>array</dt><dd><p>The x and y values converted to steps in the same order as the input;
can be unpacked as <codeclass="docutils literal notranslate"><spanclass="pre">x_out,</span><spanclass="pre">y1_out,</span><spanclass="pre">...,</span><spanclass="pre">yp_out</span></code>. If the input is
length <codeclass="docutils literal notranslate"><spanclass="pre">N</span></code>, each of these arrays will be length <codeclass="docutils literal notranslate"><spanclass="pre">2N</span><spanclass="pre">+</span><spanclass="pre">1</span></code>. For
<codeclass="docutils literal notranslate"><spanclass="pre">N=0</span></code>, the length will be 0.</p>
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">report_memory</code><spanclass="sig-paren">(</span><em><spanclass="n">i</span><spanclass="o">=</span><spanclass="default_value">0</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#report_memory"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.report_memory" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the memory consumed by the process.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.safe_first_element">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">safe_first_element</code><spanclass="sig-paren">(</span><em><spanclass="n">obj</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#safe_first_element"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.safe_first_element" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the first element in <em>obj</em>.</p>
<p>This is an type-independent way of obtaining the first element, supporting
both index access and the iterator protocol.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.safe_masked_invalid">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">safe_masked_invalid</code><spanclass="sig-paren">(</span><em><spanclass="n">x</span></em>, <em><spanclass="n">copy</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#safe_masked_invalid"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.safe_masked_invalid" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.sanitize_sequence">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">sanitize_sequence</code><spanclass="sig-paren">(</span><em><spanclass="n">data</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#sanitize_sequence"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.sanitize_sequence" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert dictview objects to list. Other inputs are returned unchanged.</p>
</dd></dl>
<dlclass="py class">
<dtid="matplotlib.cbook.silent_list">
<emclass="property">class </em><codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">silent_list</code><spanclass="sig-paren">(</span><em><spanclass="n">type</span></em>, <em><spanclass="n">seq</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#silent_list"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.silent_list" title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">simple_linear_interpolation</code><spanclass="sig-paren">(</span><em><spanclass="n">a</span></em>, <em><spanclass="n">steps</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#simple_linear_interpolation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.simple_linear_interpolation" title="Permalink to this definition">¶</a></dt>
<dd><p>Resample an array with <codeclass="docutils literal notranslate"><spanclass="pre">steps</span><spanclass="pre">-</span><spanclass="pre">1</span></code> points between original point pairs.</p>
<p>Along each column of <em>a</em>, <codeclass="docutils literal notranslate"><spanclass="pre">(steps</span><spanclass="pre">-</span><spanclass="pre">1)</span></code> points are introduced between
each original values; the values are linearly interpolated.</p>
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">strip_math</code><spanclass="sig-paren">(</span><em><spanclass="n">s</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#strip_math"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.strip_math" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove latex formatting from mathtext.</p>
<p>Only handles fully math and fully non-math strings.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.to_filehandle">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">to_filehandle</code><spanclass="sig-paren">(</span><em><spanclass="n">fname</span></em>, <em><spanclass="n">flag</span><spanclass="o">=</span><spanclass="default_value">'r'</span></em>, <em><spanclass="n">return_opened</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <em><spanclass="n">encoding</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#to_filehandle"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.to_filehandle" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a path to an open file handle or pass-through a file-like object.</p>
<p>Consider using <aclass="reference internal" href="#matplotlib.cbook.open_file_cm" title="matplotlib.cbook.open_file_cm"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">open_file_cm</span></code></a> instead, as it allows one to properly close
<dt><strong>fname</strong><spanclass="classifier">str or path-like or file-like</span></dt><dd><p>If <aclass="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">str</span></code></a> or <aclass="reference external" href="https://docs.python.org/3/library/os.html#os.PathLike" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">os.PathLike</span></code></a>, the file is opened using the flags specified
by <em>flag</em> and <em>encoding</em>. If a file-like object, it is passed through.</p>
</dd>
<dt><strong>flag</strong><spanclass="classifier">str, default 'r'</span></dt><dd><p>Passed as the <em>mode</em> argument to <aclass="reference external" href="https://docs.python.org/3/library/functions.html#open" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">open</span></code></a> when <em>fname</em> is <aclass="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">str</span></code></a> or
<aclass="reference external" href="https://docs.python.org/3/library/os.html#os.PathLike" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">os.PathLike</span></code></a>; ignored if <em>fname</em> is file-like.</p>
</dd>
<dt><strong>return_opened</strong><spanclass="classifier">bool, default False</span></dt><dd><p>If True, return both the file object and a boolean indicating whether
this was a new file (that the caller needs to close). If False, return
only the new file.</p>
</dd>
<dt><strong>encoding</strong><spanclass="classifier">str or None, default None</span></dt><dd><p>Passed as the <em>mode</em> argument to <aclass="reference external" href="https://docs.python.org/3/library/functions.html#open" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">open</span></code></a> when <em>fname</em> is <aclass="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">str</span></code></a> or
<aclass="reference external" href="https://docs.python.org/3/library/os.html#os.PathLike" title="(in Python v3.8)"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">os.PathLike</span></code></a>; ignored if <em>fname</em> is file-like.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>opened</strong><spanclass="classifier">bool</span></dt><dd><p><em>opened</em> is only returned if <em>return_opened</em> is True.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.cbook.violin_stats">
<codeclass="descclassname">matplotlib.cbook.</code><codeclass="descname">violin_stats</code><spanclass="sig-paren">(</span><em><spanclass="n">X</span></em>, <em><spanclass="n">method</span></em>, <em><spanclass="n">points</span><spanclass="o">=</span><spanclass="default_value">100</span></em>, <em><spanclass="n">quantiles</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/cbook.html#violin_stats"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.cbook.violin_stats" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of dictionaries of data which can be used to draw a series
of violin plots.</p>
<p>See the <codeclass="docutils literal notranslate"><spanclass="pre">Returns</span></code> section below to view the required keys of the
dictionary.</p>
<p>Users can skip this function and pass a user-defined set of dictionaries
with the same keys to <aclass="reference internal" href="_as_gen/matplotlib.axes.Axes.violinplot.html#matplotlib.axes.Axes.violinplot" title="matplotlib.axes.Axes.violinplot"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">violinplot</span></code></a> instead of using Matplotlib
to do the calculations. See the <em>Returns</em> section below for the keys
<dt><strong>X</strong><spanclass="classifier">array-like</span></dt><dd><p>Sample data that will be used to produce the gaussian kernel density
estimates. Must have 2 or fewer dimensions.</p>
</dd>
<dt><strong>method</strong><spanclass="classifier">callable</span></dt><dd><p>The method used to calculate the kernel density estimate for each
column of data. When called via <codeclass="docutils literal notranslate"><spanclass="pre">method(v,</span><spanclass="pre">coords)</span></code>, it should
return a vector of the values of the KDE evaluated at the values
specified in coords.</p>
</dd>
<dt><strong>points</strong><spanclass="classifier">int, default: 100</span></dt><dd><p>Defines the number of points to evaluate each of the gaussian kernel
density estimates at.</p>
</dd>
<dt><strong>quantiles</strong><spanclass="classifier">array-like, default: None</span></dt><dd><p>Defines (if not None) a list of floats in interval [0, 1] for each
column of data, which represents the quantiles that will be rendered
for that column of data. Must have 2 or fewer dimensions. 1D array will
be treated as a singleton list containing them.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">