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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
TRI | NumericArray | Yes | — | M-by-3 triangle connectivity list using MATLAB one-based vertex indices. |
X | NumericArray | Yes | — | Vertex X coordinates. |
Y | NumericArray | Yes | — | Vertex Y coordinates. |
lineSpec | StyleSpec | No | — | Line style, marker, and color shorthand. |
props | Any | Variadic | — | Name/value line style properties such as Color, LineWidth, and DisplayName. |
ax | AxesHandle | Yes | — | Target axes handle. |
TR | Any | Yes | — | Triangulation-like struct with ConnectivityList and Points fields. |
Returns
| Name | Type | Description |
|---|---|---|
h | NumericScalar | Handle to the line object containing the triangulation edges. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:triplot:InvalidArgument | Connectivity, coordinate, axes, or style inputs are malformed. | triplot: invalid argument |
RunMat:triplot:Internal | Internal 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 includingColor,LineWidth,LineStyle,DisplayName,Parent, andVisible.triplot(ax, ...)andtriplot(..., 'Parent', ax)target a specific axes.triplot(TR)accepts a struct orDelaunayTriobject withConnectivityList/Triangulationand an N-by-2 or widerPoints/Xmatrix. 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.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · axes · barh · cla · clf · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · textscatter · textscatter3 · waitbar · wordcloud · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zoom
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how triplot is executed, line by line, in Rust.
- View the source for triplot in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
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.