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

441 次查看(过去 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
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 个评论
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 中查找有关 Axis Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by