Search code examples
matlabsurf

Change Axes Tick Label in Surf - Plot


Problem

I have a surf plot based on loop data and I would like to change the appearence of the X-tick label and the Y-tick label, without changing the appearnce of the plot.

Namely I would like to multiply my X-axis by 1000 and divide my y-axis by a hundred. I have tried the following code:

Code

h=surf(results)
hold on
ax=gca;
Xlim=[200 2000];
ax.YTick=ax.YTick/100;
ax.XTick=ax.XTick*1000;
h.EdgeAlpha=0;
hold off   

The faulty Result

enter image description here

What it should look like

With the changes I implemented only the minor x and y tick label disappear and X-lim does not work either, creating this massive yellow wall that can be seen in the picture, as I have no data for the first 200 steps (before changing the tick-label).

Any help on this would be very appreciated!


Solution

  • I think that you actually wants to change the "TickLabels" (YTickLabel, XTickLabel, ...). The "Ticks" Refer to the actual values in the plot and the TickLabels refers to what is printed on the actual Tick.

    h=surf(results)
    hold on
    ax=gca;
    Xlim=[200 2000];
    yText=ax.YTick/100;
    xText=ax.XTick*1000;
    ax.YTickLabel = yText;
    ax.XTickLabel = xText;
    h.EdgeAlpha=0;
    hold off