How to combine Space and dot expressions in Matlab?
1 view (last 30 days)
Show older comments
I'm trying to include blank spaces and a dot above the greek letter psi in one label.
The command for allowing spacing is (with missing dot above psi):
plot(1:10)
ylab = sprintf('$\\psi%s [deg/s]$', repmat('\ ',1,1));
ylabel(ylab,'interpreter','latex');
The command for doing dots above a letter in tex is:
plot(1:10)
ylabel('$\dot{\phi}$', 'Interpreter','latex')
How do i combine those two?
Extra question: Is it possible to exclude the "[deg/s]" from the latex interpreter, so that it has the normal font of matlab plots and only the greek letter is in latex?
Kind regards, Sebastian
0 Comments
Answers (1)
Bjorn Gustavsson
on 21 Jan 2021
This seems to work:
ylab = sprintf('$\\dot{\\psi}%s [deg/s]$', repmat('\ ',1,12));
ylabel(ylab,'interpreter','latex');
Do you want something else?
HTH
2 Comments
Bjorn Gustavsson
on 21 Jan 2021
Ah, that I don't know. Others might be far more clever with font-manipulation when it comes to labels.
I found this (slightly discouraging) answer (from 2011, so a fair number of releases ago): latex-interpreter-different-fonts. After looking around I found more bad(?) news, but perhaps something from dpb's latex-interpreter-font-answers can get you some threads to follow, then there might be something in Yair Altman's undocumentedmatlab on latex and fonts. It is not clear to me how much of standard latex font-handling (LaTeX/Fonts) that you can cram into an ylabel-call...
This seems to work for legend-manipulation:
[l1,l2] = legend({'$\mathrm{Roman here}$','$\mathsf{SanSerif here}$','$\mathit{Italics here}$'});
set(l1,'Interpreter','latex')
set(l2(1:3),'Interpreter','latex')
(this seems like fun for the whole family...)
If you find a great, or even "good enough" solution please let us know!
HTH
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!