Italicise axis ticks (latex)
16 次查看(过去 30 天)
显示 更早的评论
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 个评论
Les Beckham
2022-3-17
You are very welcome. If I put this solution in an Answer could you accept it for me?
采纳的回答
Les Beckham
2022-3-17
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!