Italicise axis ticks (latex)

22 views (last 30 days)
Daniel Rowe
Daniel Rowe on 17 Mar 2022
Answered: Les Beckham on 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 Comments
Daniel Rowe
Daniel Rowe on 17 Mar 2022
works beautifully, thank you
Les Beckham
Les Beckham on 17 Mar 2022
You are very welcome. If I put this solution in an Answer could you accept it for me?

Sign in to comment.

Accepted Answer

Les Beckham
Les Beckham on 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.

More Answers (0)

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!