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 个评论
Daniel Rowe
Daniel Rowe 2022-3-17
works beautifully, thank you
Les Beckham
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by