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
<h1>cbook<aclass="headerlink" href="#cbook" title="Permalink to this headline">¶</a></h1>
<divclass="section" id="module-matplotlib.cbook">
<spanid="matplotlib-cbook"></span><h2><aclass="reference internal" href="#module-matplotlib.cbook" title="matplotlib.cbook"><ttclass="xref py py-mod docutils literal"><spanclass="pre">matplotlib.cbook</span></tt></a><aclass="headerlink" href="#module-matplotlib.cbook" title="Permalink to this headline">¶</a></h2>
<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="class">
<dtid="matplotlib.cbook.Bunch">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Bunch</tt><big>(</big><em>**kwds</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Bunch" title="Permalink to this definition">¶</a></dt>
<dd><p>Often we want to just collect a bunch of stuff together, naming each
item of the bunch; a dictionary’s OK for that, but a small do- nothing
class is even handier, and prettier to use. Whenever you want to
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">CallbackRegistry</tt><big>(</big><em>*args</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.CallbackRegistry" title="Permalink to this definition">¶</a></dt>
<dd><p>Handle registering and disconnecting for a set of signals and
<spanclass="gp">>>> </span><spanclass="n">callbacks</span><spanclass="o">.</span><spanclass="n">process</span><spanclass="p">(</span><spanclass="s">'be merry'</span><spanclass="p">,</span><spanclass="mi">456</span><spanclass="p">)</span><spanclass="c"># nothing will be called</span>
<spanclass="gp">>>> </span><spanclass="n">callbacks</span><spanclass="o">.</span><spanclass="n">process</span><spanclass="p">(</span><spanclass="s">'eat'</span><spanclass="p">,</span><spanclass="mi">456</span><spanclass="p">)</span><spanclass="c"># 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 CallbackRegistry won’t keep
it alive. The Python stdlib weakref module can not create weak
references to bound methods directly, so we need to create a proxy
object to handle weak references to bound methods (or regular free
functions). This technique was shared by Peter Parente on his
<ttclass="descname">connect</tt><big>(</big><em>s</em>, <em>func</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.CallbackRegistry.connect" title="Permalink to this definition">¶</a></dt>
<dd><p>register <em>func</em> to be called when a signal <em>s</em> is generated
<ttclass="descname">disconnect</tt><big>(</big><em>cid</em><big>)</big><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>
<ttclass="descname">process</tt><big>(</big><em>s</em>, <em>*args</em>, <em>**kwargs</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.CallbackRegistry.process" title="Permalink to this definition">¶</a></dt>
<dd><p>process signal <em>s</em>. All of the functions registered to receive
callbacks on <em>s</em> will be called with <em>*args</em> and <em>**kwargs</em></p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.GetRealpathAndStat">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">GetRealpathAndStat</tt><aclass="headerlink" href="#matplotlib.cbook.GetRealpathAndStat" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.Grouper">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Grouper</tt><big>(</big><em>init=</em><spanclass="optional">[</span><spanclass="optional">]</span><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Grouper" title="Permalink to this definition">¶</a></dt>
<p>This class provides a lightweight way to group arbitrary objects
together into disjoint sets when a full-blown graph data structure
would be overkill.</p>
<p>Objects can be joined using <aclass="reference internal" href="#matplotlib.cbook.Grouper.join" title="matplotlib.cbook.Grouper.join"><ttclass="xref py py-meth docutils literal"><spanclass="pre">join()</span></tt></a>, tested for connectedness
using <aclass="reference internal" href="#matplotlib.cbook.Grouper.joined" title="matplotlib.cbook.Grouper.joined"><ttclass="xref py py-meth docutils literal"><spanclass="pre">joined()</span></tt></a>, and all disjoint sets can be retreived by
using the object as an iterator.</p>
<p>The objects being joined must be hashable and weak-referenceable.</p>
<ttclass="descname">clean</tt><big>(</big><big>)</big><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="method">
<dtid="matplotlib.cbook.Grouper.get_siblings">
<ttclass="descname">get_siblings</tt><big>(</big><em>a</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Grouper.get_siblings" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns all of the items joined with <em>a</em>, including itself.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Grouper.join">
<ttclass="descname">join</tt><big>(</big><em>a</em>, <em>*args</em><big>)</big><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="method">
<dtid="matplotlib.cbook.Grouper.joined">
<ttclass="descname">joined</tt><big>(</big><em>a</em>, <em>b</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Grouper.joined" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if <em>a</em> and <em>b</em> are members of the same set.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.Idle">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Idle</tt><big>(</big><em>func</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Idle" title="Permalink to this definition">¶</a></dt>
<ttclass="descname">run</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Idle.run" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="matplotlib.cbook.Idle.waittime">
<ttclass="descname">waittime</tt><emclass="property"> = 0.05</em><aclass="headerlink" href="#matplotlib.cbook.Idle.waittime" title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">MatplotlibDeprecationWarning</tt><aclass="headerlink" href="#matplotlib.cbook.MatplotlibDeprecationWarning" title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">MemoryMonitor</tt><big>(</big><em>nmax=20000</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.MemoryMonitor" title="Permalink to this definition">¶</a></dt>
<dd><dlclass="method">
<dtid="matplotlib.cbook.MemoryMonitor.clear">
<ttclass="descname">clear</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.cbook.MemoryMonitor.clear" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.MemoryMonitor.plot">
<ttclass="descname">plot</tt><big>(</big><em>i0=0</em>, <em>isub=1</em>, <em>fig=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.MemoryMonitor.plot" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.MemoryMonitor.report">
<ttclass="descname">report</tt><big>(</big><em>segments=4</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.MemoryMonitor.report" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.MemoryMonitor.xy">
<ttclass="descname">xy</tt><big>(</big><em>i0=0</em>, <em>isub=1</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.MemoryMonitor.xy" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.Null">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Null</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Null" title="Permalink to this definition">¶</a></dt>
<dd><p>Null objects always and reliably “do nothing.”</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.RingBuffer">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">RingBuffer</tt><big>(</big><em>size_max</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.RingBuffer" title="Permalink to this definition">¶</a></dt>
<dd><p>class that implements a not-yet-full buffer</p>
<dlclass="method">
<dtid="matplotlib.cbook.RingBuffer.append">
<ttclass="descname">append</tt><big>(</big><em>x</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.RingBuffer.append" title="Permalink to this definition">¶</a></dt>
<dd><p>append an element at the end of the buffer</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.RingBuffer.get">
<ttclass="descname">get</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.cbook.RingBuffer.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of elements from the oldest to the newest.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.Scheduler">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Scheduler</tt><aclass="headerlink" href="#matplotlib.cbook.Scheduler" title="Permalink to this definition">¶</a></dt>
<ttclass="descname">id</tt><emclass="property"> = 0</em><aclass="headerlink" href="#matplotlib.cbook.Scheduler.id" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="matplotlib.cbook.Scheduler.idlelock">
<ttclass="descname">idlelock</tt><emclass="property"> = <thread.lock object at 0x15d9730></em><aclass="headerlink" href="#matplotlib.cbook.Scheduler.idlelock" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Scheduler.stop">
<ttclass="descname">stop</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Scheduler.stop" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.Sorter">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Sorter</tt><aclass="headerlink" href="#matplotlib.cbook.Sorter" title="Permalink to this definition">¶</a></dt>
<spanclass="n">sort</span><spanclass="p">(</span><spanclass="nb">list</span><spanclass="p">,</span><spanclass="mi">1</span><spanclass="p">)</span><spanclass="c"># sort by index 1</span>
<spanclass="n">sort</span><spanclass="p">(</span><spanclass="nb">dict</span><spanclass="p">,</span><spanclass="s">'a'</span><spanclass="p">)</span><spanclass="c"># sort a list of dicts by key 'a'</span>
</pre></div>
</div>
<dlclass="method">
<dtid="matplotlib.cbook.Sorter.byAttribute">
<ttclass="descname">byAttribute</tt><big>(</big><em>data</em>, <em>attributename</em>, <em>inplace=1</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Sorter.byAttribute" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Sorter.byItem">
<ttclass="descname">byItem</tt><big>(</big><em>data</em>, <em>itemindex=None</em>, <em>inplace=1</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Sorter.byItem" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Sorter.sort">
<ttclass="descname">sort</tt><big>(</big><em>data</em>, <em>itemindex=None</em>, <em>inplace=1</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Sorter.sort" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.Stack">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Stack</tt><big>(</big><em>default=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Stack" title="Permalink to this definition">¶</a></dt>
<p>Implement a stack where elements can be pushed on and you can move
back and forth. But no pop. Should mimic home / back / forward
in a browser</p>
<dlclass="method">
<dtid="matplotlib.cbook.Stack.back">
<ttclass="descname">back</tt><big>(</big><big>)</big><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="method">
<dtid="matplotlib.cbook.Stack.bubble">
<ttclass="descname">bubble</tt><big>(</big><em>o</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Stack.bubble" title="Permalink to this definition">¶</a></dt>
<dd><p>raise <em>o</em> to the top of the stack and return <em>o</em>. <em>o</em> must be
in the stack</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Stack.clear">
<ttclass="descname">clear</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Stack.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>empty the stack</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Stack.empty">
<ttclass="descname">empty</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Stack.empty" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Stack.forward">
<ttclass="descname">forward</tt><big>(</big><big>)</big><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="method">
<dtid="matplotlib.cbook.Stack.home">
<ttclass="descname">home</tt><big>(</big><big>)</big><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>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Stack.push">
<ttclass="descname">push</tt><big>(</big><em>o</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Stack.push" title="Permalink to this definition">¶</a></dt>
<dd><p>push object onto stack at current position - all elements
occurring later than the current position are discarded</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.cbook.Stack.remove">
<ttclass="descname">remove</tt><big>(</big><em>o</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Stack.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>remove element <em>o</em> from the stack</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.Timeout">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Timeout</tt><big>(</big><em>wait</em>, <em>func</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Timeout" title="Permalink to this definition">¶</a></dt>
<p>Schedule recurring events with a wait time in seconds</p>
<dlclass="method">
<dtid="matplotlib.cbook.Timeout.run">
<ttclass="descname">run</tt><big>(</big><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Timeout.run" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.Xlator">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">Xlator</tt><aclass="headerlink" href="#matplotlib.cbook.Xlator" title="Permalink to this definition">¶</a></dt>
<divclass="highlight-python"><divclass="highlight"><pre><spanclass="n">text</span><spanclass="o">=</span><spanclass="s">"Larry Wall is the creator of Perl"</span>
<ttclass="descname">xlat</tt><big>(</big><em>text</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.Xlator.xlat" title="Permalink to this definition">¶</a></dt>
<dd><p>Translate <em>text</em>, returns the modified text.</p>
</dd></dl>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.align_iterators">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">align_iterators</tt><big>(</big><em>func</em>, <em>*iterables</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.align_iterators" title="Permalink to this definition">¶</a></dt>
<dd><p>This generator takes a bunch of iterables that are ordered by func
It sends out ordered tuples:</p>
<divclass="highlight-python"><pre>(func(row), [rows from all iterators matching func(row)])</pre>
</div>
<p>It is used by <aclass="reference internal" href="mlab_api.html#matplotlib.mlab.recs_join" title="matplotlib.mlab.recs_join"><ttclass="xref py py-func docutils literal"><spanclass="pre">matplotlib.mlab.recs_join()</span></tt></a> to join record arrays</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.allequal">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">allequal</tt><big>(</big><em>seq</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.allequal" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <em>True</em> if all elements of <em>seq</em> compare equal. If <em>seq</em> is
0 or 1 length, return <em>True</em></p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.allpairs">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">allpairs</tt><big>(</big><em>x</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.allpairs" title="Permalink to this definition">¶</a></dt>
<dd><p>return all possible pairs in sequence <em>x</em></p>
<p>Condensed by Alex Martelli from this <aclass="reference external" href="http://groups.google.com/groups?q=all+pairs+group:*python*&hl=en&lr=&ie=UTF-8&selm=mailman.4028.1096403649.5135.python-list%40python.org&rnum=1">thread</a> on c.l.python</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.alltrue">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">alltrue</tt><big>(</big><em>seq</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.alltrue" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <em>True</em> if all elements of <em>seq</em> evaluate to <em>True</em>. If
<em>seq</em> is empty, return <em>False</em>.</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.converter">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">converter</tt><big>(</big><em>missing='Null'</em>, <em>missingval=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.converter" title="Permalink to this definition">¶</a></dt>
<p>Base class for handling string -> python type with support for
missing values</p>
<dlclass="method">
<dtid="matplotlib.cbook.converter.is_missing">
<ttclass="descname">is_missing</tt><big>(</big><em>s</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.converter.is_missing" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.dedent">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">dedent</tt><big>(</big><em>s</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.dedent" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove excess indentation from docstring <em>s</em>.</p>
<p>Discards any leading blank lines, then removes up to n whitespace
characters from each line, where n is the number of leading
whitespace characters in the first line. It differs from
textwrap.dedent in its deletion of leading blank lines and its use
of the first non-blank line to determine the indentation.</p>
<p>It is also faster in most cases.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.delete_masked_points">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">delete_masked_points</tt><big>(</big><em>*args</em><big>)</big><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 <ttclass="xref py py-meth docutils literal"><spanclass="pre">np.isfinite()</span></tt>
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="function">
<dtid="matplotlib.cbook.dict_delall">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">dict_delall</tt><big>(</big><em>d</em>, <em>keys</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.dict_delall" title="Permalink to this definition">¶</a></dt>
<dd><p>delete all of the <em>keys</em> from the <ttclass="xref py py-class docutils literal"><spanclass="pre">dict</span></tt><em>d</em></p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.exception_to_str">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">exception_to_str</tt><big>(</big><em>s=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.exception_to_str" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.finddir">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">finddir</tt><big>(</big><em>o</em>, <em>match</em>, <em>case=False</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.finddir" title="Permalink to this definition">¶</a></dt>
<dd><p>return all attributes of <em>o</em> which match string in match. if case
is True require an exact case match.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.flatten">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">flatten</tt><big>(</big><em>seq</em>, <em>scalarp=<function is_scalar_or_string at 0x1d20aa0></em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.flatten" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a generator of flattened nested containers</p>
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">get_recursive_filelist</tt><big>(</big><em>args</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.get_recursive_filelist" title="Permalink to this definition">¶</a></dt>
<dd><p>Recurse all the files and dirs in <em>args</em> ignoring symbolic links
and return the files as a list of strings</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.get_sample_data">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">get_sample_data</tt><big>(</big><em>fname</em>, <em>asfileobj=True</em><big>)</big><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
<ttclass="xref py py-obj docutils literal"><spanclass="pre">mpl-data/sample_data</span></tt> directory. If <em>asfileobj</em> is <ttclass="xref py py-obj docutils literal"><spanclass="pre">True</span></tt>
return a file object, otherwise just a file path.</p>
<p>Set the rc parameter examples.directory to the directory where we should
look, if sample_data files are stored in a location different than
default (which is ‘mpl-data/sample_data` at the same level of ‘matplotlib`
Python module files).</p>
<p>If the filename ends in .gz, the file is implicitly ungzipped.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.get_split_ind">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">get_split_ind</tt><big>(</big><em>seq</em>, <em>N</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.get_split_ind" title="Permalink to this definition">¶</a></dt>
<dd><p><em>seq</em> is a list of words. Return the index into seq such that:</p>
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">is_math_text</tt><big>(</big><em>s</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.is_math_text" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.is_numlike">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">is_numlike</tt><big>(</big><em>obj</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.is_numlike" title="Permalink to this definition">¶</a></dt>
<dd><p>return true if <em>obj</em> looks like a number</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.is_scalar">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">is_scalar</tt><big>(</big><em>obj</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.is_scalar" title="Permalink to this definition">¶</a></dt>
<dd><p>return true if <em>obj</em> is not string like and is not iterable</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.is_scalar_or_string">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">is_scalar_or_string</tt><big>(</big><em>val</em><big>)</big><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="function">
<dtid="matplotlib.cbook.is_sequence_of_strings">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">is_sequence_of_strings</tt><big>(</big><em>obj</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.is_sequence_of_strings" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns true if <em>obj</em> is iterable and contains strings</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.is_string_like">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">is_string_like</tt><big>(</big><em>obj</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.is_string_like" title="Permalink to this definition">¶</a></dt>
<dd><p>Return True if <em>obj</em> looks like a string</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.is_writable_file_like">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">is_writable_file_like</tt><big>(</big><em>obj</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.is_writable_file_like" title="Permalink to this definition">¶</a></dt>
<dd><p>return true if <em>obj</em> looks like a file object with a <em>write</em> method</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.issubclass_safe">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">issubclass_safe</tt><big>(</big><em>x</em>, <em>klass</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.issubclass_safe" title="Permalink to this definition">¶</a></dt>
<dd><p>return issubclass(x, klass) and return False on a TypeError</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.iterable">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">iterable</tt><big>(</big><em>obj</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.iterable" title="Permalink to this definition">¶</a></dt>
<dd><p>return true if <em>obj</em> is iterable</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.listFiles">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">listFiles</tt><big>(</big><em>root</em>, <em>patterns='*'</em>, <em>recurse=1</em>, <em>return_folders=0</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.listFiles" title="Permalink to this definition">¶</a></dt>
<dd><p>Recursively list files</p>
<p>from Parmar and Martelli in the Python Cookbook</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.maxdict">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">maxdict</tt><big>(</big><em>maxsize</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.maxdict" title="Permalink to this definition">¶</a></dt>
<p>A dictionary with a maximum size; this doesn’t override all the
relevant methods to contrain size, just setitem, so use with
caution</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.mkdirs">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">mkdirs</tt><big>(</big><em>newdir</em>, <em>mode=511</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.mkdirs" title="Permalink to this definition">¶</a></dt>
<dd><p>make directory <em>newdir</em> recursively, and set <em>mode</em>. Equivalent to</p>
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">mplDeprecation</tt><aclass="headerlink" href="#matplotlib.cbook.mplDeprecation" title="Permalink to this definition">¶</a></dt>
<dd><p>alias of <aclass="reference internal" href="#matplotlib.cbook.MatplotlibDeprecationWarning" title="matplotlib.cbook.MatplotlibDeprecationWarning"><ttclass="xref py py-class docutils literal"><spanclass="pre">MatplotlibDeprecationWarning</span></tt></a></p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.onetrue">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">onetrue</tt><big>(</big><em>seq</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.onetrue" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <em>True</em> if one element of <em>seq</em> is <em>True</em>. It <em>seq</em> is
empty, return <em>False</em>.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.pieces">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">pieces</tt><big>(</big><em>seq</em>, <em>num=2</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.pieces" title="Permalink to this definition">¶</a></dt>
<dd><p>Break up the <em>seq</em> into <em>num</em> tuples</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.popall">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">popall</tt><big>(</big><em>seq</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.popall" title="Permalink to this definition">¶</a></dt>
<dd><p>empty a list</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.print_cycles">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">print_cycles</tt><big>(</big><em>objects</em>, <em>outstream=<open file '<stdout>'</em>, <em>mode 'w' at 0x7fb3f687c1e0></em>, <em>show_progress=False</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.print_cycles" title="Permalink to this definition">¶</a></dt>
<dd><dlclass="docutils">
<dt><em>objects</em></dt>
<dd>A list of objects to find cycles in. It is often useful to
pass in gc.garbage to find the cycles that are preventing some
objects from being garbage collected.</dd>
<dt><em>outstream</em></dt>
<dd>The stream for output.</dd>
<dt><em>show_progress</em></dt>
<dd>If True, print the number of objects reached as they are found.</dd>
</dl>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.recursive_remove">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">recursive_remove</tt><big>(</big><em>path</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.recursive_remove" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.report_memory">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">report_memory</tt><big>(</big><em>i=0</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.report_memory" title="Permalink to this definition">¶</a></dt>
<dd><p>return the memory consumed by process</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.restrict_dict">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">restrict_dict</tt><big>(</big><em>d</em>, <em>keys</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.restrict_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a dictionary that contains those keys that appear in both
d and keys, with values from d.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.reverse_dict">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">reverse_dict</tt><big>(</big><em>d</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.reverse_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>reverse the dictionary – may lose data if values are not unique!</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.safe_masked_invalid">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">safe_masked_invalid</tt><big>(</big><em>x</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.safe_masked_invalid" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.safezip">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">safezip</tt><big>(</big><em>*args</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.safezip" title="Permalink to this definition">¶</a></dt>
<dd><p>make sure <em>args</em> are equal len before zipping</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.silent_list">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">silent_list</tt><big>(</big><em>type</em>, <em>seq=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.silent_list" title="Permalink to this definition">¶</a></dt>
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">simple_linear_interpolation</tt><big>(</big><em>a</em>, <em>steps</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.simple_linear_interpolation" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.soundex">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">soundex</tt><big>(</big><em>name</em>, <em>len=4</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.soundex" title="Permalink to this definition">¶</a></dt>
<dd><p>soundex module conforming to Odell-Russell algorithm</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.strip_math">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">strip_math</tt><big>(</big><em>s</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.strip_math" title="Permalink to this definition">¶</a></dt>
<dd><p>remove latex formatting from mathtext</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.to_filehandle">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">to_filehandle</tt><big>(</big><em>fname</em>, <em>flag='rU'</em>, <em>return_opened=False</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.to_filehandle" title="Permalink to this definition">¶</a></dt>
<dd><p><em>fname</em> can be a filename or a file handle. Support for gzipped
files is automatic, if the filename ends in .gz. <em>flag</em> is a
read/write flag for <ttclass="xref py py-func docutils literal"><spanclass="pre">file()</span></tt></p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.todate">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">todate</tt><big>(</big><em>fmt='%Y-%m-%d'</em>, <em>missing='Null'</em>, <em>missingval=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.todate" title="Permalink to this definition">¶</a></dt>
<p>use a <ttclass="xref py py-func docutils literal"><spanclass="pre">time.strptime()</span></tt> format string for conversion</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.todatetime">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">todatetime</tt><big>(</big><em>fmt='%Y-%m-%d'</em>, <em>missing='Null'</em>, <em>missingval=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.todatetime" title="Permalink to this definition">¶</a></dt>
<p>use a <ttclass="xref py py-func docutils literal"><spanclass="pre">time.strptime()</span></tt> format string for conversion</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.cbook.tofloat">
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">tofloat</tt><big>(</big><em>missing='Null'</em>, <em>missingval=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.tofloat" title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">toint</tt><big>(</big><em>missing='Null'</em>, <em>missingval=None</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.toint" title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">tostr</tt><big>(</big><em>missing='Null'</em>, <em>missingval=''</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.tostr" title="Permalink to this definition">¶</a></dt>
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">unicode_safe</tt><big>(</big><em>s</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.unicode_safe" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.unique">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">unique</tt><big>(</big><em>x</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.unique" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of unique elements of <em>x</em></p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.unmasked_index_ranges">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">unmasked_index_ranges</tt><big>(</big><em>mask</em>, <em>compressed=True</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.unmasked_index_ranges" title="Permalink to this definition">¶</a></dt>
<dd><p>Find index ranges where <em>mask</em> is <em>False</em>.</p>
<p><em>mask</em> will be flattened if it is not already 1-D.</p>
<p>Returns Nx2 <ttclass="xref py py-class docutils literal"><spanclass="pre">numpy.ndarray</span></tt> with each row the start and stop
indices for slices of the compressed <ttclass="xref py py-class docutils literal"><spanclass="pre">numpy.ndarray</span></tt>
corresponding to each of <em>N</em> uninterrupted runs of unmasked
values. If optional argument <em>compressed</em> is <em>False</em>, it returns
the start and stop indices into the original <ttclass="xref py py-class docutils literal"><spanclass="pre">numpy.ndarray</span></tt>,
not the compressed <ttclass="xref py py-class docutils literal"><spanclass="pre">numpy.ndarray</span></tt>. Returns <em>None</em> if there
<p>Prior to the transforms refactoring, this was used to support
masked arrays in Line2D.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.cbook.wrap">
<ttclass="descclassname">matplotlib.cbook.</tt><ttclass="descname">wrap</tt><big>(</big><em>prefix</em>, <em>text</em>, <em>cols</em><big>)</big><aclass="headerlink" href="#matplotlib.cbook.wrap" title="Permalink to this definition">¶</a></dt>
<dd><p>wrap <em>text</em> with <em>prefix</em> at length <em>cols</em></p>