ticklabels with LaTeX interpreter disappear
21 views (last 30 days)
Show older comments
Yanick Frei
on 10 May 2023
Commented: Yanick Frei
on 10 May 2023
Hello
I have a problem generating some plots in Matlab. I would like to create labels for the x- and y-axis, containing LaTeX symbols. After plotting, I use the following code:
xticks([0, GE.LVRT.t_clear, 3*GE.LVRT.t_clear, 3*GE.LVRT.t_clear+GE.LVRT.t_rec3]);
xticklabels({'0', 't_{clear,\rm{LVRT}}', 't_{rec2,\rm{LVRT}}', 't_{rec3,\rm{LVRT}}'}, 'TickLabelInterpreter', 'latex');
Which creates an error.
Error using xticklabels (line 43)
Too many input arguments.
Error in VoltageProfile_GridEmulator (line 29)
xticklabels({'0', 't_{clear,\rm{LVRT}}', 't_{rec2,\rm{LVRT}}', 't_{rec3,\rm{LVRT}}'}, 'TickLabelInterpreter', 'latex')
An alternative approach has been to use
set(0, 'defaultAxesTickLabelInterpreter', 'latex');
in my startup-file, as this is a setting I generally would like to have for all my figures. Doing so and removing the interpreter statement, no error is generated, however, the labels disappear. The same happens with
set(gca,'TickLabelInterpreter','latex')
So the question is what am I doing wrong? I can reproduce this behavior also with older versions of Matlab.
Thank you in advance for your help.
0 Comments
Accepted Answer
Walter Roberson
on 10 May 2023
xticklabels({'0', '$t_{clear,\rm{LVRT}}$', '$t_{rec2,\rm{LVRT}}$', '$t_{rec3,\rm{LVRT}}$'});
set(gca, 'TickLabelInterpreter', 'latex')
More Answers (0)
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!