Changing the scale of axis in surf plot

18 visualizaciones (últimos 30 días)
Ajinkya Potphode
Ajinkya Potphode el 30 de Abr. de 2019
Comentada: Mauro Gisbert Verdú el 11 de Mzo. de 2020
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.

Respuesta aceptada

Adam Danz
Adam Danz el 30 de Abr. de 2019
Editada: Adam Danz el 30 de Abr. de 2019
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);
  9 comentarios
Bibek Dhami
Bibek Dhami el 6 de Mayo de 2019
Hi
I have similar problem. How can I make a surf plot with y axis having two diffrent scale. for y from -10 to 10 , I need linear scale and from10 to 3000, I need log scale.
Adam Danz
Adam Danz el 6 de Mayo de 2019
Hi Bibek, that's not really similar to this problem. It's not possible to assign two axis scales to a single axis. You can kludge it in by changing the tick marks, though. I suggest asking a new question.

Iniciar sesión para comentar.

Más respuestas (1)

Mauro Gisbert Verdú
Mauro Gisbert Verdú el 11 de Mzo. de 2020
If you know the specific limits of your axis, may you use the x,y - ticklabels funtion. It works perfectly
Example:
xticklabels({80 85 90 95 100})
yticklabels({20 25 30 35 40})
  2 comentarios
Adam Danz
Adam Danz el 11 de Mzo. de 2020
I wouldn't recommend this approach because the real x and y values for your data are no longer represented in the plot. This makes troubleshooting difficult and it can be misleading to viewers who aren't familiar with the code or your future-self who has forgotten that he tick labels have been changed.
It's much better to change the actual x and y values in your data so that the axis ticks represent the actual data values.
Mauro Gisbert Verdú
Mauro Gisbert Verdú el 11 de Mzo. de 2020
I agree, however when you work with codificated variables the response surface change acording to tbis data. Its more understadable plot with real variables although the plot was with the codificated.

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by