MATLAB: Changing the scale of axis in surf plot

shiftshift datasurfplot

Hello,
I plotted a 3D graph using 'surf' function. I want to change the axis scale to different values. My X-axis is 0:10:70. I want to convert X-axis to a scale having 0 at center of the axis and -35 and +35 on the both sides. Is it possible to do that?
Thanks in advance.

Best Answer

How to change the limits and ticks on the x axis
h = surf(X,Y,Z); % save handle to surface object
axHand = h.Parent; % alternative: gca()
axHand.XTick = -35 : 5 : 35;
axHand.XLim = [-35, 35];
How to shift your data down the x axis
shift = -35; %shift 35 units leftward (neg) or rightward (pos)
h = surf(X+shift, Y, Z);