Italicise axis ticks (latex)

22 ビュー (過去 30 日間)
Daniel Rowe
Daniel Rowe 2022 年 3 月 17 日
回答済み: Les Beckham 2022 年 3 月 17 日
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 Center および File ExchangeAnnotations についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by