MATLAB Answers

Combining multiple colors and latex commands as tick labels

1 view (last 30 days)
Leo Simon
Leo Simon on 21 Apr 2020
Commented: Leo Simon on 21 Apr 2020
I want to have some ticklabels as colored symbols and others as symbols like \bar{x}. These desires seem to be incompatible.
To get the colored symbols I need the 'tex' interpreter; to get \bar{x} I need the 'latex' interpreter.
The following example illustrates the problem. If you run it to the keyboard, you'll see the colored lsymbols together with \$\bar{x}\$
This seems to be because the tex intepreter doesn't know what to do with the \bar command. Same problem with \tilde, \hat, etc.
If you go past the keyboard and switch interpreters, you'll see but the colored symbols disappear, because it seems the latex interpreter doesn't know what to do with the colored symbols. Is there any way to reconcile this incompatibility? Thanks!

Accepted Answer

Mehmed Saad
Mehmed Saad on 21 Apr 2020
Edited: Mehmed Saad on 21 Apr 2020
You can use this instead of that
x = gca;
pos = x.XTick;
poy = min(ylim)-0.05;
x.XTickLabel= ' ';
sybs = {'$\bar{x}$','\lambda','\theta','$\bar{x}$','\lambda','\theta','$\bar{x}$',...
intp = {'latex','tex','tex','latex','tex','tex','latex','tex','tex','latex','tex'};
for i=1:length(pos)
  1 Comment
Leo Simon
Leo Simon on 21 Apr 2020
Perfect, thanks! This means i can abandon matlab's tick label implementation forever, which is very liberating!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!