triplot — Draw the edges of a 2-D triangular mesh.

triplot plots the edges of a 2-D triangulation. The common numeric form accepts an M-by-3 one-based connectivity matrix plus X and Y coordinate vectors. RunMat also accepts triangulation-like structs or DelaunayTri objects with connectivity and point properties for compatibility with saved or user-constructed triangulation data.

Syntax

h = triplot(TRI, X, Y)
h = triplot(TRI, X, Y, LineSpec)
h = triplot(TRI, X, Y, Name, Value, ...)
h = triplot(ax, TRI, X, Y)
h = triplot(TR)
h = triplot(TR, LineSpec)
h = triplot(ax, TR, ...)

Inputs

NameTypeRequiredDefaultDescription
TRINumericArrayYesM-by-3 triangle connectivity list using MATLAB one-based vertex indices.
XNumericArrayYesVertex X coordinates.
YNumericArrayYesVertex Y coordinates.
lineSpecStyleSpecNoLine style, marker, and color shorthand.
propsAnyVariadicName/value line style properties such as Color, LineWidth, and DisplayName.
axAxesHandleYesTarget axes handle.
TRAnyYesTriangulation-like struct with ConnectivityList and Points fields.

Returns

NameTypeDescription
hNumericScalarHandle to the line object containing the triangulation edges.

Errors

IdentifierWhenMessage
RunMat:triplot:InvalidArgumentConnectivity, coordinate, axes, or style inputs are malformed.triplot: invalid argument
RunMat:triplot:InternalInternal line construction or plotting state update fails.triplot: internal operation failed

How triplot works

  • triplot(TRI, X, Y) draws all triangle edges as one line graphics object.
  • triplot(TRI, X, Y, LineSpec) applies MATLAB line shorthand such as 'r--'.
  • triplot(TRI, X, Y, Name, Value, ...) supports shared line styling properties including Color, LineWidth, LineStyle, DisplayName, Parent, and Visible.
  • triplot(ax, ...) and triplot(..., 'Parent', ax) target a specific axes.
  • triplot(TR) accepts a struct or DelaunayTri object with ConnectivityList/Triangulation and an N-by-2 or wider Points/X matrix. The first two point columns are used as X and Y coordinates.
  • Connectivity entries must be positive finite integer indices within the coordinate vectors.

Examples

Plot a two-triangle square mesh

TRI = [1 2 3; 2 4 3];
X = [0 1 0 1];
Y = [0 0 1 1];
h = triplot(TRI, X, Y);

Style triangulation edges

TRI = [1 2 3];
X = [0 1 0];
Y = [0 0 1];
h = triplot(TRI, X, Y, 'r--', 'LineWidth', 2, 'DisplayName', 'mesh');

Use a triangulation-like struct or object

TR.ConnectivityList = [1 2 3];
TR.Points = [0 0; 1 0; 0 1];
triplot(TR);
dt = DelaunayTri(TR.Points);
triplot(dt);

Using triplot with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how triplot changes the result.

Run a small triplot example, explain the result, then change one input and compare the output.

FAQ

What does triplot return?

triplot returns the line graphics handle containing the triangulation edges. The handle can be queried and styled with get and set like other line objects.

Does triplot render filled triangles?

No. triplot draws mesh edges only. Use patch-style graphics when filled faces are needed.

Does triplot preserve gpuArray residency?

No. The current implementation gathers connectivity and point data before constructing the edge list. It is a plotting sink, and the produced line object follows the normal line renderer path.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how triplot is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.