text — Add text at a position in a 2-D or 3-D plot.
text(x,y,txt) adds an annotation at a 2-D position. Include z for a 3-D position, or provide an axes handle first to select the target axes.
Syntax
h = text(x, y, label)
h = text(x, y, label, Name, Value, ...)
h = text(x, y, z, label)
h = text(x, y, z, label, Name, Value, ...)
h = text(ax, x, y, label)
h = text(ax, x, y, z, label)All supported text forms
h = text(x, y, label)
h = text(x, y, label, Name, Value, ...)
h = text(x, y, z, label)
h = text(x, y, z, label, Name, Value, ...)
h = text(ax, x, y, label)
h = text(ax, x, y, z, label)
text(x, y, label)
text(x, y, label, Name, Value, ...)
text(x, y, z, label)
text(x, y, z, label, Name, Value, ...)
text(ax, x, y, label)
text(ax, x, y, z, label)Inputs
x- Type
NumericScalar- Required
- Yes
- Description
- X coordinate.
y- Type
NumericScalar- Required
- Yes
- Description
- Y coordinate.
label- Type
StringScalar- Required
- Yes
- Description
- Annotation text.
props- Type
Any- Required
- Variadic
- Description
- Name/value style options.
z- Type
NumericScalar- Required
- Yes
- Description
- Z coordinate.
ax- Type
AxesHandle- Required
- Yes
- Description
- Target axes handle.
Returns
h- Type
NumericScalar- Description
- Handle to the created text annotation.
Errors
RunMat:text:InvalidArgument- When
- Coordinate, label, axes-target, or name/value text style arguments are invalid.
- Message
text: invalid argument
RunMat:text:Internal- When
- Internal plotting state update fails while creating annotation.
- Message
text: internal operation failed
RunMat:text:TooManyOutputs- When
- More than one output is requested.
- Message
text: too many output arguments
Behavior
Coordinates can use single, double, or any of the eight integer classes.
The Position property retains the coordinate class, shape, and exact values. Rendering uses a separate floating-point geometry cache.
A two-element Position value is stored with a third coordinate of zero in the same numeric class.
The returned graphics handle supports get and set for String, Position, FontWeight, FontAngle, Interpreter, Color, FontSize, and Visible.
Typed-integer numeric axes aliases and explicit gpuArray coordinates are RunMat-mode extensions.
Placement and execution
This command mutates local graphics scene state and may notify the graphics host. Inputs and returned graphics handles are host-owned; worker transfer of numeric handle values does not transfer scene ownership.
Interpreter and compiled routes use the same runtime operation; a browser graphics host or desktop graphics host is required for presentation.
Examples
Label a point on a curve
plot(1:5, [2 4 3 5 4]);
h = text(4, 5, "peak");Add a 3-D annotation
plot3(1:3, 2:4, 5:7);
h = text(2, 3, 6, "sample");Use integer coordinates
h = text(int64(12), int64(-3), "checkpoint");
position = get(h, "Position")Expected output:
position = 1×3 int64
12 -3 0Using text with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how text changes the result.
Run a small text example, explain the result, then change one input and compare the output.
FAQ
Are integer positions converted to double?⌄
No. The graphics property keeps native integer storage and exact values. Only the derived coordinates sent to the renderer are converted.
Can text label several points in one call?⌄
Not yet. Each call currently accepts one scalar 2-D or 3-D position; vector coordinates and per-point label arrays remain unsupported.
Can I pass resident coordinates?⌄
Automatically resident coordinates are gathered transparently through their owning provider. Explicit gpuArray coordinates require RunMat mode because the current public compatibility target does not document an interactive GPU form for text.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
Source you can read
Every RunMat function's source is public. Read exactly how text is executed, line by line, in Rust.
- View the source for text in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.