How can I use an interpreter (like LaTeX) when setting axis markers?
조회 수: 489 (최근 30일)
이전 댓글 표시
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
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
2015년 6월 6일
Read about the properties XTick, YTick and ZTick:
And then try the (empty) vector []
Les Beckham
2015년 6월 6일
Try the TickLength property of the axes. set(gca, 'TickLength', [0 0]) eliminates the ticks.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!