<divid="unreleased-message"> You are reading an old version of the documentation (v3.0.2). For the latest version see <ahref="https://matplotlib.org/stable/api/tri_api.html">https://matplotlib.org/stable/api/tri_api.html</a></div>
<codeclass="descname">calculate_plane_coefficients</code><spanclass="sig-paren">(</span><em>z</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triangulation.html#Triangulation.calculate_plane_coefficients"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.Triangulation.calculate_plane_coefficients" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculate plane equation coefficients for all unmasked triangles from
the point (x, y) coordinates and specified z-array of shape (npoints).
The returned array has shape (npoints, 3) and allows z-value at (x, y)
<codeclass="descname">get_cpp_triangulation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triangulation.html#Triangulation.get_cpp_triangulation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.Triangulation.get_cpp_triangulation" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the underlying C++ Triangulation object, creating it
<emclass="property">static </em><codeclass="descname">get_from_args_and_kwargs</code><spanclass="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triangulation.html#Triangulation.get_from_args_and_kwargs"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.Triangulation.get_from_args_and_kwargs" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a Triangulation object from the args and kwargs, and
the remaining args and kwargs with the consumed values removed.</p>
<p>There are two alternatives: either the first argument is a
Triangulation object, in which case it is returned, or the args
and kwargs are sufficient to create a new Triangulation to
return. In the latter case, see Triangulation.__init__ for
<codeclass="descname">get_masked_triangles</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triangulation.html#Triangulation.get_masked_triangles"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.Triangulation.get_masked_triangles" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an array of triangles that are not masked.</p>
<codeclass="descname">get_trifinder</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triangulation.html#Triangulation.get_trifinder"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.Triangulation.get_trifinder" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the default <aclass="reference internal" href="#matplotlib.tri.TriFinder" title="matplotlib.tri.TriFinder"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">matplotlib.tri.TriFinder</span></code></a> of this
triangulation, creating it if necessary. This allows the same
TriFinder object to be easily shared.</p>
</dd></dl>
<dlclass="attribute">
<dtid="matplotlib.tri.Triangulation.neighbors">
<codeclass="descname">neighbors</code><aclass="headerlink" href="#matplotlib.tri.Triangulation.neighbors" title="Permalink to this definition">¶</a></dt>
<dd><p>Return integer array of shape (ntri, 3) containing neighbor
triangles.</p>
<p>For each triangle, the indices of the three triangles that
share the same edges, or -1 if there is no such neighboring
triangle. neighbors[i,j] is the triangle that is the neighbor
to the edge from point index triangles[i,j] to point index
triangles[i,(j+1)%3].</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.tri.Triangulation.set_mask">
<codeclass="descname">set_mask</code><spanclass="sig-paren">(</span><em>mask</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triangulation.html#Triangulation.set_mask"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.Triangulation.set_mask" title="Permalink to this definition">¶</a></dt>
<dd><p>Set or clear the mask array. This is either None, or a boolean
array of shape (ntri).</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.tri.TriFinder">
<emclass="property">class </em><codeclass="descclassname">matplotlib.tri.</code><codeclass="descname">TriFinder</code><spanclass="sig-paren">(</span><em>triangulation</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/trifinder.html#TriFinder"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.TriFinder" title="Permalink to this definition">¶</a></dt>
<dd><p>Abstract base class for classes used to find the triangles of a
Triangulation in which (x,y) points lie.</p>
<p>Rather than instantiate an object of a class derived from TriFinder, it is
<p>Derived classes implement __call__(x,y) where x,y are array_like point
coordinates of the same shape.</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.tri.TrapezoidMapTriFinder">
<emclass="property">class </em><codeclass="descclassname">matplotlib.tri.</code><codeclass="descname">TrapezoidMapTriFinder</code><spanclass="sig-paren">(</span><em>triangulation</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/trifinder.html#TrapezoidMapTriFinder"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.TrapezoidMapTriFinder" title="Permalink to this definition">¶</a></dt>
<p><aclass="reference internal" href="#matplotlib.tri.TriFinder" title="matplotlib.tri.TriFinder"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">TriFinder</span></code></a> class implemented using the trapezoid
map algorithm from the book "Computational Geometry, Algorithms and
Applications", second edition, by M. de Berg, M. van Kreveld, M. Overmars
and O. Schwarzkopf.</p>
<p>The triangulation must be valid, i.e. it must not have duplicate points,
triangles formed from colinear points, or overlapping triangles. The
algorithm has some tolerance to triangles formed from colinear points, but
this should not be relied upon.</p>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.tri.TriInterpolator">
<emclass="property">class </em><codeclass="descclassname">matplotlib.tri.</code><codeclass="descname">TriInterpolator</code><spanclass="sig-paren">(</span><em>triangulation</em>, <em>z</em>, <em>trifinder=None</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triinterpolate.html#TriInterpolator"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.TriInterpolator" title="Permalink to this definition">¶</a></dt>
<dd><p>Abstract base class for classes used to perform interpolation on
triangular grids.</p>
<p>Derived classes implement the following methods:</p>
<codeclass="descname">gradient</code><spanclass="sig-paren">(</span><em>x</em>, <em>y</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triinterpolate.html#LinearTriInterpolator.gradient"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.LinearTriInterpolator.gradient" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a list of 2 masked arrays containing interpolated derivatives
<dd><pclass="first">Choice of the smoothing algorithm, in order to compute
the interpolant derivatives (defaults to 'min_E'):</p>
<blockquoteclass="last">
<div><ulclass="simple">
<li>if 'min_E': (default) The derivatives at each node is computed
to minimize a bending energy.</li>
<li>if 'geom': The derivatives at each node is computed as a
weighted average of relevant triangle normals. To be used for
speed optimization (large grids).</li>
<li>if 'user': The user provides the argument <codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">dz</span></code>, no computation
<tr><tdclass="label">[1]</td><td><em>(<aclass="fn-backref" href="#id1">1</a>, <aclass="fn-backref" href="#id3">2</a>)</em> Michel Bernadou, Kamal Hassan, "Basis functions for general
Hsieh-Clough-Tocher triangles, complete or reduced.",
International Journal for Numerical Methods in Engineering,
<codeclass="descname">gradient</code><spanclass="sig-paren">(</span><em>x</em>, <em>y</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triinterpolate.html#CubicTriInterpolator.gradient"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.CubicTriInterpolator.gradient" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a list of 2 masked arrays containing interpolated derivatives
<emclass="property">class </em><codeclass="descclassname">matplotlib.tri.</code><codeclass="descname">TriRefiner</code><spanclass="sig-paren">(</span><em>triangulation</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/trirefine.html#TriRefiner"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.TriRefiner" title="Permalink to this definition">¶</a></dt>
<dd><p>Abstract base class for classes implementing mesh refinement.</p>
<p>A TriRefiner encapsulates a Triangulation object and provides tools for
mesh refinement and interpolation.</p>
<p>Derived classes must implements:</p>
<blockquote>
<div><ul>
<li><pclass="first"><codeclass="docutils literal notranslate"><spanclass="pre">refine_triangulation(return_tri_index=False,</span><spanclass="pre">**kwargs)</span></code> , where
the optional keyword arguments <em>kwargs</em> are defined in each
TriRefiner concrete implementation, and which returns :</p>
<blockquote>
<div><ulclass="simple">
<li>a refined triangulation</li>
<li>optionally (depending on <em>return_tri_index</em>), for each
point of the refined triangulation: the index of
the initial triangulation triangle to which it belongs.</li>
<li>the other optional keyword arguments <em>kwargs</em> are defined in
each TriRefiner concrete implementation</li>
</ul>
</div></blockquote>
<p>and which returns (as a tuple) a refined triangular mesh and the
interpolated values of the field at the refined triangulation nodes.</p>
</li>
</ul>
</div></blockquote>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.tri.UniformTriRefiner">
<emclass="property">class </em><codeclass="descclassname">matplotlib.tri.</code><codeclass="descname">UniformTriRefiner</code><spanclass="sig-paren">(</span><em>triangulation</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/trirefine.html#UniformTriRefiner"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.UniformTriRefiner" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">refine_field</code><spanclass="sig-paren">(</span><em>z</em>, <em>triinterpolator=None</em>, <em>subdiv=3</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/trirefine.html#UniformTriRefiner.refine_field"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.UniformTriRefiner.refine_field" title="Permalink to this definition">¶</a></dt>
<dd><p>Refines a field defined on the encapsulated triangulation.</p>
<codeclass="descname">refine_triangulation</code><spanclass="sig-paren">(</span><em>return_tri_index=False</em>, <em>subdiv=3</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/trirefine.html#UniformTriRefiner.refine_triangulation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.UniformTriRefiner.refine_triangulation" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes an uniformly refined triangulation <em>refi_triangulation</em> of
the encapsulated <codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">triangulation</span></code>.</p>
<p>This function refines the encapsulated triangulation by splitting each
father triangle into 4 child sub-triangles built on the edges midside
nodes, recursively (level of recursion <em>subdiv</em>).
In the end, each triangle is hence divided into <codeclass="docutils literal notranslate"><spanclass="pre">4**subdiv</span></code>
child triangles.
The default value for <em>subdiv</em> is 3 resulting in 64 refined
subtriangles for each triangle of the initial triangulation.</p>
<dd><pclass="first last">The returned refined triangulation</p>
</dd>
<dt><strong>found_index</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">array-like of integers</span></dt>
<dd><pclass="first last">Index of the initial triangulation containing triangle, for each
point of <em>refi_triangulation</em>.
Returned only if <em>return_tri_index</em> is set to True.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.tri.TriAnalyzer">
<emclass="property">class </em><codeclass="descclassname">matplotlib.tri.</code><codeclass="descname">TriAnalyzer</code><spanclass="sig-paren">(</span><em>triangulation</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/tritools.html#TriAnalyzer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.TriAnalyzer" title="Permalink to this definition">¶</a></dt>
<dd><p>Define basic tools for triangular mesh analysis and improvement.</p>
<dd><pclass="first last">The encapsulated triangulation to analyze.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Attributes:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>`scale_factors`</strong></dt>
<dd></dd>
</dl>
</td>
</tr>
</tbody>
</table>
<dlclass="method">
<dtid="matplotlib.tri.TriAnalyzer.circle_ratios">
<codeclass="descname">circle_ratios</code><spanclass="sig-paren">(</span><em>rescale=True</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/tritools.html#TriAnalyzer.circle_ratios"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.TriAnalyzer.circle_ratios" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a measure of the triangulation triangles flatness.</p>
<p>The ratio of the incircle radius over the circumcircle radius is a
widely used indicator of a triangle flatness.
It is always <codeclass="docutils literal notranslate"><spanclass="pre"><=</span><spanclass="pre">0.5</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">==</span><spanclass="pre">0.5</span></code> only for equilateral
triangles. Circle ratios below 0.01 denote very flat triangles.</p>
<p>To avoid unduly low values due to a difference of scale between the 2
axis, the triangular mesh can first be rescaled to fit inside a unit
square with <aclass="reference internal" href="#matplotlib.tri.TriAnalyzer.scale_factors" title="matplotlib.tri.TriAnalyzer.scale_factors"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">scale_factors</span></code></a> (Only if <em>rescale</em> is True, which is
<dd><pclass="first last">If True, a rescaling will be internally performed (based on
<aclass="reference internal" href="#matplotlib.tri.TriAnalyzer.scale_factors" title="matplotlib.tri.TriAnalyzer.scale_factors"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">scale_factors</span></code></a>, so that the (unmasked) triangles fit
exactly inside a unit square mesh. Default is True.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<codeclass="descname">get_flat_tri_mask</code><spanclass="sig-paren">(</span><em>min_circle_ratio=0.01</em>, <em>rescale=True</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/tritools.html#TriAnalyzer.get_flat_tri_mask"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.TriAnalyzer.get_flat_tri_mask" title="Permalink to this definition">¶</a></dt>
<dd><p>Eliminates excessively flat border triangles from the triangulation.</p>
<p>Returns a mask <em>new_mask</em> which allows to clean the encapsulated
triangulation from its border-located flat triangles
(according to their <aclass="reference internal" href="#matplotlib.tri.TriAnalyzer.circle_ratios" title="matplotlib.tri.TriAnalyzer.circle_ratios"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">circle_ratios()</span></code></a>).
This mask is meant to be subsequently applied to the triangulation
using <aclass="reference internal" href="#matplotlib.tri.Triangulation.set_mask" title="matplotlib.tri.Triangulation.set_mask"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">matplotlib.tri.Triangulation.set_mask()</span></code></a>.
<em>new_mask</em> is an extension of the initial triangulation mask
in the sense that an initially masked triangle will remain masked.</p>
<p>The <em>new_mask</em> array is computed recursively; at each step flat
triangles are removed only if they share a side with the current mesh
border. Thus no new holes in the triangulated domain will be created.</p>
<dd><pclass="first last">If True, a rescaling will first be internally performed (based on
<aclass="reference internal" href="#matplotlib.tri.TriAnalyzer.scale_factors" title="matplotlib.tri.TriAnalyzer.scale_factors"><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">scale_factors</span></code></a> ), so that the (unmasked) triangles fit
exactly inside a unit square mesh. This rescaling accounts for the
difference of scale which might exist between the 2 axis. Default
(and recommended) value is True.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>new_mask</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">array-like of booleans</span></dt>
<dd><pclass="first last">Mask to apply to encapsulated triangulation.
All the initially masked triangles remain masked in the
<em>new_mask</em>.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>The rationale behind this function is that a Delaunay
triangulation - of an unstructured set of points - sometimes contains
almost flat triangles at its border, leading to artifacts in plots
(especially for high-resolution contouring).
Masked with computed <em>new_mask</em>, the encapsulated
triangulation would contain no more unmasked border triangles
with a circle ratio below <em>min_circle_ratio</em>, thus improving the
mesh quality for subsequent plots or interpolation.</p>
</dd></dl>
<dlclass="attribute">
<dtid="matplotlib.tri.TriAnalyzer.scale_factors">
<codeclass="descname">scale_factors</code><aclass="headerlink" href="#matplotlib.tri.TriAnalyzer.scale_factors" title="Permalink to this definition">¶</a></dt>
<dd><p>Factors to rescale the triangulation into a unit square.</p>
<p>Returns <em>k</em>, tuple of 2 scale factors.</p>