How can I use an interpreter (like LaTeX) when setting axis markers?

조회 수: 489 (최근 30일)
Mark
Mark 2015년 6월 5일
댓글: Himanshu Giria 2022년 7월 22일
I essentially have a contour plot on which I'd like to label each row and column. I can do this with text, but I would like to use the LaTeX formatting instead. So instead of labeling something 'a', I would like to label it '$\alpha_x$'. If I was doing an axis label, I know that the following works:
xlabel('$\alpha_x$','interpreter','latex')
and would like to do something similar for the axis markers. Here's what I have so far:
figure
set(gcf,'color','white')
[X,Y] = meshgrid(0.5:5.5);
Z = X.^2+ Y.^2
pcolor(X,Y,Z);
list = ['a'; 'b'; 'c'; 'd'; 'e'];
set(gca,'XLim',[.5 5.5]);
set(gca,'XTick',[1:5]);
set(gca,'XTickLabel',list)
set(gca,'YLim',[.5 5.5]);
set(gca,'YTick',[1:5]);
set(gca,'YTickLabel',list)
colorbar
If possible I'd also like to make the ticks themselves invsible, but that is a tertiary goal. Writing:
set('gca','YTicklabel',list,'interpreter','latex')
produces the error:
Error using set
Invalid property found.
Object Name: axes
Property Name: 'interpreter'.

채택된 답변

Mike Garrity
Mike Garrity 2015년 6월 5일
I assume that by "marker" you mean "ticklabel"? If so, it is separate from the interpreter which is used for titles and labels. In R2014a or earlier, you didn't have control over this interpreter. It was chosen automatically.
In R2014b, there's a new property on the Axes named TickLabelInterpreter which lets you control it.
set(gca,'TickLabelInterpreter','latex')
  댓글 수: 3
Stephen23
Stephen23 2015년 6월 6일
Read about the properties XTick, YTick and ZTick:
And then try the (empty) vector []
Les Beckham
Les Beckham 2015년 6월 6일
Try the TickLength property of the axes. set(gca, 'TickLength', [0 0]) eliminates the ticks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by