Italicise axis ticks (latex)
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Daniel Rowe
le 17 Mar 2022
Réponse apportée : Les Beckham
le 17 Mar 2022
Hi,
I'm this is simple to answer but I'd be grateful if somebody could share their wisdom.
Basically, I want to offset the first x axis value from the y axis (rather than them overlapping by default), hence why I've specified my range of x to be four values, though I only want to plot against three of them. Then I want to apply a cell array of characters to the x axis, however, when I try to italicise the characters, it doesn't work.
Below is a stripped down version of my code.
% variables
V_i = {' ','u','v','w'};
x = 0:1:3;
y = rand(3,3)*10;
% Plotting
plot(x(2:4),y)
xlim([0 3])
xticks(0:1:3)
% Naming
title('Variance','Interpreter','latex')
ylabel('$\sigma^{2}$ (m$^{2}$/s$^{2}$)','Interpreter','latex')
set(gca,'xtick',[0:3],'xticklabel',V_i,'FontAngle', 'italic')
5 commentaires
Les Beckham
le 17 Mar 2022
You are very welcome. If I put this solution in an Answer could you accept it for me?
Réponse acceptée
Les Beckham
le 17 Mar 2022
Try changing
V_i = {' ','u','v','w'};
to
V_i = {' ','\textit{u}','\textit{v}','\textit{w}'}; % latex code for italics
and change
set(gca,'xtick',[0:3],'xticklabel',V_i,'FontAngle', 'italic')
to
set(gca,'xtick', [0:3], 'xticklabel', V_i)
That seems to work.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!