How can I use '$...$' Environment in xticklabel with matlab2tikz?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Wan Ji
2021년 8월 29일
Just use
xticklabels({'\$1\$','','\$2\$','','\$3\$','','\$4\$','','\$5\$',''});
rather than
xticklabels({'$1$','','$2$','','$3$','','$4$','','$5$',''});
댓글 수: 2
Wan Ji
2021년 8월 29일
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));
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!