How can I use '$...$' Environment in xticklabel with matlab2tikz?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Simon Beer
am 29 Aug. 2021
Kommentiert: Wan Ji
am 29 Aug. 2021
Hello,
I am generating a tikzpicture with following Code:
X = 1:1:10;
Y = sin(X);
plot(X,Y);
xticks(X);
xticklabels({'$1$','','$2$','','$3$','','$4$','','$5$',''});
cleanfigure;
matlab2tikz('testfig.tex', 'showInfo', false);
the generated lines for the xticklabels are: (Full Code attached)
xtick={1,2,3,4,5,6,7,8,9,10},
xticklabels={{\$1\$},{},{\$2\$},{},{\$3\$},{},{\$4\$},{},{\$5\$},{}},
Is there a way to tell matlab2tikz, not to interpret the text and exchange $ with \$ but just take it as is?
The compiled Picture looks like this:
For the Y-axis, math font is used, but as labels are often text, for the X-axis the normal text font style is used, why I tried with $$ environment.
So my original Problem is simply, that I dont want every ticklabel to be printed, but have it both in math font style.
I appreciate any help or workaround for this problem. Probably I am missing something as these are my first tries with this package.
Simon
0 Kommentare
Akzeptierte Antwort
Wan Ji
am 29 Aug. 2021
Just use
xticklabels({'\$1\$','','\$2\$','','\$3\$','','\$4\$','','\$5\$',''});
rather than
xticklabels({'$1$','','$2$','','$3$','','$4$','','$5$',''});
2 Kommentare
Wan Ji
am 29 Aug. 2021
The tiks and ticklabel can be written in
x_tick = X(1:2:end);
xticks(x_tick);
xticklabels(arrayfun(@(i)['\$',num2str(x_tick(i)),'\$'],1:length(x_tick),'uniform',0));
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!