How to include an arrow as text in the label of a plot?

The axes of figures for publications adhering DIN 461 respectively include an arrow that points in the same direction that the value indicated by the corresponding axis is rising, see this example. According to DIN 461, there are two options to do this: One can put the arrow either at the end of the axis or parallel to it next to the label. As I prefer the second option, how do I include an arrow as text in the label of a plot? For the abscissa, I need an arrow that points to the right, and for the ordinate, I need an arrow that points upwards. I apply 'latex' for 'Interpreter' if that matters.

 Réponse acceptée

Use respectively '\leftarrow ','\rightarrow', or \uparrow' or '\downarroa' depending on what you want.
Example --
figure
plot(randn(50,1), randn(50,1))
grid
xlabel('$Increading \rightarrow$', Interpreter='LaTeX')
ylabel('$\leftarrow Decreasing$', Interpreter='LaTeX')
.

3 commentaires

Specifically with respect to the example provided --
figure
plot((1:50)+0.5, randn(50,1))
grid
xlabel('$\vartheta / ^\circ C \rightarrow$', Interpreter='LaTeX')
ylabel(["$\uparrow$" "$R/\Omega$"], Interpreter='LaTeX', Rotation=0, Horiz='center')
Getting the ylabel to be the same as the example requires a bit more coding. Axis labels are text objects so see that documentation for details on working with them.
.
Thanks for the extra info! Is there a way to change the appearance of the arrow head from the standard mathematical one to something like 'LaTeX' or 'Triangle' in this list of arrow heads?
My pleasure!
The 'LaTeX' arrowhead would be something similar to what MATLAB uses in its LaTeX fonts, as provided here. The only ones that may be available are on p.67 of The Not So Short Introduction to LaTeX 2e. Those are likely the only options for text arrows, and then only if MATLAB supports them (not guaranteed).
The quiver plot function has arrows, although it is unlikely that you can use them in text.
Any other arrows you may want you would probably have to cut/paste to be adjascent to a text object.
It might be worth looking through the File Exchange to see if there are text arrow options. Searching on 'text arrow' just now produced this.

Connectez-vous pour commenter.

Plus de réponses (1)

dpb
dpb le 23 Fév 2026
Déplacé(e) : dpb le 23 Fév 2026
plot(randn(5,1))
xlabel('X label $\rightarrow$','Interpreter','latex')
ylabel('Y label $\rightarrow$','Interpreter','latex')

2 commentaires

Is there a way to change the appearance of the arrow head from the standard mathematical one to something like 'LaTeX' or 'Triangle' in this list of arrow heads?
dpb
dpb le 24 Fév 2026
Modifié(e) : dpb le 24 Fév 2026
Probably not; afaik, nobody has ever yet figured out any way to add a package to the embedded LaTeX distribution used by MATLAB.
Unless it is in the base LaTex or math symbols, I think you're stuck with what can be done inside MATLAB directly. You could possibly create an image outside of MATLAB and overlay it in the desired location sorta' like the second text object instead of inline text as used here (I didn't actually go read the doc to see the exact format spec).
If you can find the syntax to use, you can always just try and see if it is recognized by the LaTeX interpreter, but it's almost certainly not going to be unless it is in the plain vanilla base package.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Labels and Annotations dans Centre d'aide et File Exchange

Produits

Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by