X Y grids on 2D surface plot

I'm facing problem in making visible the grids for the x and y axis.
Her is a simple exemple:
[X,Y,Z] = peaks(25);
surf(X,Y,Z)
shading interp;
grid on
view(2)
Please, any help?

 Respuesta aceptada

Star Strider
Star Strider el 6 de Dic. de 2019

0 votos

If you want to see the grid lines, do not use shading interp
Just do:
[X,Y,Z] = peaks(25);
figure
surf(X, Y, Z)
grid on
view(2)
and the grid lines will be visible,.

4 comentarios

Toufik
Toufik el 7 de Dic. de 2019
First of all thanks for your answer. If I don't use shading interp, I will get the lines over all the figure and I don't want this. What I want to see is a grid lines on the figure only one the points specified by xtick and ytick.
Star Strider
Star Strider el 7 de Dic. de 2019
My pleasure.
Try this:
[X,Y,Z] = peaks(25);
figure
surf(X, Y, Z)
hold on
xl = xlim;
yl = ylim;
zl = zlim;
xt = xl(1):xl(2);
yt = yl(1):yl(2);
plot3([xt; xt], yl(:)*ones(size(xt)), ones(2,numel(xt))*max(zl),':k')
plot3(xl(:)*ones(size(yt)), [yt; yt], ones(2,numel(yt))*max(zl),':k')
hold off
grid on
view(2)
shading('interp')
Make appropriate changes to get the result you want.
Toufik
Toufik el 7 de Dic. de 2019
Thank you very much, it works like that.
Star Strider
Star Strider el 7 de Dic. de 2019
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 6 de Dic. de 2019

Comentada:

el 7 de Dic. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by