<divid="unreleased-message"> You are reading an old version of the documentation (v3.3.0). For the latest version see <ahref="https://matplotlib.org/stable/api/tri_api.html">https://matplotlib.org/stable/api/tri_api.html</a></div>
<spanid="matplotlib-tri"></span><h1><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib.tri</span></code><aclass="headerlink" href="#module-matplotlib.tri" title="Permalink to this headline">¶</a></h1>
<p>Unstructured triangular grid functions.</p>
<dlclass="class">
<dtid="matplotlib.tri.Triangulation">
<emclass="property">class </em><codeclass="descclassname">matplotlib.tri.</code><codeclass="descname">Triangulation</code><spanclass="sig-paren">(</span><em>x</em>, <em>y</em>, <em>triangles=None</em>, <em>mask=None</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tri/triangulation.html#Triangulation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tri.Triangulation" title="Permalink to this definition">¶</a></dt>
<dd><p>An unstructured triangular grid consisting of npoints points and
ntri triangles. The triangles can either be specified by the user
or automatically generated using a Delaunay triangulation.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>x, y</strong><spanclass="classifier">array-like of shape (npoints)</span></dt><dd><p>Coordinates of grid points.</p>
</dd>
<dt><strong>triangles</strong><spanclass="classifier">int array-like of shape (ntri, 3), optional</span></dt><dd><p>For each triangle, the indices of the three points that make
up the triangle, ordered in an anticlockwise manner. If not
specified, the Delaunay triangulation is calculated.</p>
</dd>
<dt><strong>mask</strong><spanclass="classifier">bool array-like of shape (ntri), optional</span></dt><dd><p>Which triangles are masked out.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>For a Triangulation to be valid it must not have duplicate points,
triangles formed from colinear points, or overlapping triangles.</p>
<codeclass="descname">calculate_plane_coefficients</code><spanclass="sig-paren">(</span><em>self</em>, <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)
<emclass="property">property </em><codeclass="descname">edges</code><aclass="headerlink" href="#matplotlib.tri.Triangulation.edges" title="Permalink to this definition">¶</a></dt>
<dd><p>Return integer array of shape (nedges, 2) containing all edges of
non-masked triangles.</p>
<p>Each row defines an edge by it's start point index and end point
index. Each edge appears only once, i.e. for an edge between points
<em>i</em> and <em>j</em>, there will only be either <em>(i, j)</em> or <em>(j, i)</em>.</p>
<codeclass="descname">get_cpp_triangulation</code><spanclass="sig-paren">(</span><em>self</em><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><em>self</em><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><em>self</em><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-obj 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="method">
<dtid="matplotlib.tri.Triangulation.neighbors">
<emclass="property">property </em><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. <codeclass="docutils literal notranslate"><spanclass="pre">neighbors[i,</span><spanclass="pre">j]</span></code> is the triangle that is the neighbor
to the edge from point index <codeclass="docutils literal notranslate"><spanclass="pre">triangles[i,</span><spanclass="pre">j]</span></code> to point index
<codeclass="descname">set_mask</code><spanclass="sig-paren">(</span><em>self</em>, <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>
<dt><strong>layers</strong></dt><dd><p>Same as levels for line contours; half-way between
levels for filled contours. See <codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">_process_colors()</span></code>.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<p>Draw triangular grid contour lines or filled regions,
depending on whether keyword arg 'filled' is False
(default) or True.</p>
<p>The first argument of the initializer must be an axes
object. The remaining arguments and keyword arguments
are described in the docstring of <aclass="reference internal" href="_as_gen/matplotlib.axes.Axes.tricontour.html#matplotlib.axes.Axes.tricontour" title="matplotlib.axes.Axes.tricontour"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">tricontour</span></code></a>.</p>
</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
usually better to use the function <aclass="reference internal" href="#matplotlib.tri.Triangulation.get_trifinder" title="matplotlib.tri.Triangulation.get_trifinder"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Triangulation.get_trifinder</span></code></a>.</p>
<p>Derived classes implement __call__(x, y) where x and 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-obj 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 interpolate on a triangular grid.</p>
<p>Derived classes implement the following methods:</p>
<dt><strong>z</strong><spanclass="classifier">array-like of shape (npoints,)</span></dt><dd><p>Array of values, defined at grid points, to interpolate between.</p>
</dd>
<dt><strong>trifinder</strong><spanclass="classifier"><aclass="reference internal" href="#matplotlib.tri.TriFinder" title="matplotlib.tri.TriFinder"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">TriFinder</span></code></a>, optional</span></dt><dd><p>If this is not specified, the Triangulation's default TriFinder will
be used by calling <aclass="reference internal" href="#matplotlib.tri.Triangulation.get_trifinder" title="matplotlib.tri.Triangulation.get_trifinder"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Triangulation.get_trifinder</span></code></a>.</p>
<codeclass="descname">gradient</code><spanclass="sig-paren">(</span><em>self</em>, <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
<dt><strong>x, y</strong><spanclass="classifier">array-like</span></dt><dd><p>x and y coordinates of the same shape and any number of
dimensions.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>dzdx, dzdy</strong><spanclass="classifier">np.ma.array</span></dt><dd><p>2 masked arrays of the same shape as <em>x</em> and <em>y</em>; values
corresponding to (x, y) points outside of the triangulation
are masked out.
The first returned array contains the values of
<spanclass="math notranslate nohighlight">\(\frac{\partial z}{\partial x}\)</span> and the second those of
<dt><strong>z</strong><spanclass="classifier">array-like of shape (npoints,)</span></dt><dd><p>Array of values, defined at grid points, to interpolate between.</p>
</dd>
<dt><strong>kind</strong><spanclass="classifier">{'min_E', 'geom', 'user'}, optional</span></dt><dd><p>Choice of the smoothing algorithm, in order to compute
the interpolant derivatives (defaults to 'min_E'):</p>
<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 <em>dz</em>, no computation
is hence needed.</li>
</ul>
</dd>
<dt><strong>trifinder</strong><spanclass="classifier"><aclass="reference internal" href="#matplotlib.tri.TriFinder" title="matplotlib.tri.TriFinder"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">TriFinder</span></code></a>, optional</span></dt><dd><p>If not specified, the Triangulation's default TriFinder will
be used by calling <aclass="reference internal" href="#matplotlib.tri.Triangulation.get_trifinder" title="matplotlib.tri.Triangulation.get_trifinder"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Triangulation.get_trifinder</span></code></a>.</p>
</dd>
<dt><strong>dz</strong><spanclass="classifier">tuple of array-likes (dzdx, dzdy), optional</span></dt><dd><p>Used only if <em>kind</em> ='user'. In this case <em>dz</em> must be provided as
(dzdx, dzdy) where dzdx, dzdy are arrays of the same shape as <em>z</em> and
are the interpolant first derivatives at the <em>triangulation</em> points.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<pclass="rubric">Notes</p>
<p>This note is a bit technical and details how the cubic interpolation is
computed.</p>
<p>The interpolation is based on a Clough-Tocher subdivision scheme of
the <em>triangulation</em> mesh (to make it clearer, each triangle of the
grid will be divided in 3 child-triangles, and on each child triangle
the interpolated function is a cubic polynomial of the 2 coordinates).
This technique originates from FEM (Finite Element Method) analysis;
the element used is a reduced Hsieh-Clough-Tocher (HCT)
element. Its shape functions are described in <aclass="reference internal" href="#r0be0c58fd53f-1" id="id1"><span>[R0be0c58fd53f-1]</span></a>.
The assembled function is guaranteed to be C1-smooth, i.e. it is
continuous and its first derivatives are also continuous (this
is easy to show inside the triangles but is also true when crossing the
edges).</p>
<p>In the default case (<em>kind</em> ='min_E'), the interpolant minimizes a
curvature energy on the functional space generated by the HCT element
shape functions - with imposed values but arbitrary derivatives at each
node. The minimized functional is the integral of the so-called total
curvature (implementation based on an algorithm from <aclass="reference internal" href="#r0be0c58fd53f-2" id="id2"><span>[R0be0c58fd53f-2]</span></a> - PCG sparse
<codeclass="descname">gradient</code><spanclass="sig-paren">(</span><em>self</em>, <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
<dt><strong>x, y</strong><spanclass="classifier">array-like</span></dt><dd><p>x and y coordinates of the same shape and any number of
dimensions.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>dzdx, dzdy</strong><spanclass="classifier">np.ma.array</span></dt><dd><p>2 masked arrays of the same shape as <em>x</em> and <em>y</em>; values
corresponding to (x, y) points outside of the triangulation
are masked out.
The first returned array contains the values of
<spanclass="math notranslate nohighlight">\(\frac{\partial z}{\partial x}\)</span> and the second those of
<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 implement:</p>
<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>
<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><em>z</em> array of field values (to refine) defined at the base
triangulation nodes,</li>
<li><em>triinterpolator</em> is an optional <aclass="reference internal" href="#matplotlib.tri.TriInterpolator" title="matplotlib.tri.TriInterpolator"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">TriInterpolator</span></code></a>,</li>
<li>the other optional keyword arguments <em>kwargs</em> are defined in
each TriRefiner concrete implementation;</li>
</ul>
<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>
</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>
<dt><strong>z</strong><spanclass="classifier">1d-array-like of length <codeclass="docutils literal notranslate"><spanclass="pre">n_points</span></code></span></dt><dd><p>Values of the field to refine, defined at the nodes of the
encapsulated triangulation. (<codeclass="docutils literal notranslate"><spanclass="pre">n_points</span></code> is the number of points
in the initial triangulation)</p>
</dd>
<dt><strong>triinterpolator</strong><spanclass="classifier"><aclass="reference internal" href="#matplotlib.tri.TriInterpolator" title="matplotlib.tri.TriInterpolator"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">TriInterpolator</span></code></a>, optional</span></dt><dd><p>Interpolator used for field interpolation. If not specified,
a <aclass="reference internal" href="#matplotlib.tri.CubicTriInterpolator" title="matplotlib.tri.CubicTriInterpolator"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">CubicTriInterpolator</span></code></a> will be used.</p>
</dd>
<dt><strong>subdiv</strong><spanclass="classifier">int, default: 3</span></dt><dd><p>Recursion level for the subdivision.
Each triangle is divided into <codeclass="docutils literal notranslate"><spanclass="pre">4**subdiv</span></code> child triangles.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>refi_z</strong><spanclass="classifier">1d array of length: <em>refi_tri</em> node count.</span></dt><dd><p>The returned interpolated field (at <em>refi_tri</em> nodes).</p>
<codeclass="descname">refine_triangulation</code><spanclass="sig-paren">(</span><em>self</em>, <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>Compute 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, recursing <em>subdiv</em> times. In the end, each triangle is hence
divided into <codeclass="docutils literal notranslate"><spanclass="pre">4**subdiv</span></code> child triangles.</p>
<dt><strong>return_tri_index</strong><spanclass="classifier">bool, default: False</span></dt><dd><p>Whether an index table indicating the father triangle index of each
point is returned.</p>
</dd>
<dt><strong>subdiv</strong><spanclass="classifier">int, default: 3</span></dt><dd><p>Recursion level for the subdivision.
Each triangle is divided into <codeclass="docutils literal notranslate"><spanclass="pre">4**subdiv</span></code> child triangles;
hence, the default results in 64 refined subtriangles for each
triangle of the initial triangulation.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>found_index</strong><spanclass="classifier">int array</span></dt><dd><p>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>
<p>A TriAnalyzer encapsulates a <aclass="reference internal" href="#matplotlib.tri.Triangulation" title="matplotlib.tri.Triangulation"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Triangulation</span></code></a> object and provides basic
<trclass="field-even field"><thclass="field-name">Attributes:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><aclass="reference internal" href="#matplotlib.tri.TriAnalyzer.scale_factors" title="matplotlib.tri.TriAnalyzer.scale_factors"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">scale_factors</span></code></a></dt><dd><p>Factors to rescale the triangulation into a unit square.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<dlclass="method">
<dtid="matplotlib.tri.TriAnalyzer.circle_ratios">
<codeclass="descname">circle_ratios</code><spanclass="sig-paren">(</span><em>self</em>, <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>Return 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-obj docutils literal notranslate"><spanclass="pre">scale_factors</span></code></a> (Only if <em>rescale</em> is True, which is
<dt><strong>rescale</strong><spanclass="classifier">bool, default: True</span></dt><dd><p>If True, internally rescale (based on <aclass="reference internal" href="#matplotlib.tri.TriAnalyzer.scale_factors" title="matplotlib.tri.TriAnalyzer.scale_factors"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">scale_factors</span></code></a>), so that the
(unmasked) triangles fit exactly inside a unit square mesh.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>masked array</dt><dd><p>Ratio of the incircle radius over the circumcircle radius, for
each 'rescaled' triangle of the encapsulated triangulation.
Values corresponding to masked triangles are masked out.</p>
<codeclass="descname">get_flat_tri_mask</code><spanclass="sig-paren">(</span><em>self</em>, <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>Eliminate 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-obj docutils literal notranslate"><spanclass="pre">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>
<dt><strong>min_circle_ratio</strong><spanclass="classifier">float, default: 0.01</span></dt><dd><p>Border triangles with incircle/circumcircle radii ratio r/R will
be removed if r/R < <em>min_circle_ratio</em>.</p>
</dd>
<dt><strong>rescale</strong><spanclass="classifier">bool, default: True</span></dt><dd><p>If True, first, internally rescale (based on <aclass="reference internal" href="#matplotlib.tri.TriAnalyzer.scale_factors" title="matplotlib.tri.TriAnalyzer.scale_factors"><codeclass="xref py py-obj 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.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>bool array-like</dt><dd><p>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="method">
<dtid="matplotlib.tri.TriAnalyzer.scale_factors">
<emclass="property">property </em><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>