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

496 Ansichten (letzte 30 Tage)
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'.

Akzeptierte Antwort

Mike Garrity
Mike Garrity am 5 Jun. 2015
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 Kommentare
Stephen23
Stephen23 am 6 Jun. 2015
Read about the properties XTick, YTick and ZTick:
And then try the (empty) vector []
Les Beckham
Les Beckham am 6 Jun. 2015
Try the TickLength property of the axes. set(gca, 'TickLength', [0 0]) eliminates the ticks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by