Discussion:
Smooth shading with visible grid lines
(too old to reply)
Erik de Boer
2010-12-28 16:12:05 UTC
Permalink
Hello,

A surface that I am plotting is difficult to comprehend without its grid lines. At the same time I like to smooth the color shading because some parts of the plot otherwise appear 'patched'.

To smooth the shading I use 'shading interp'. This function does away with the grid lines. I wasn't able to restore the grid lines, for example by adding 'grid on'.

Is there any way to smooth shading in a surf plot without losing the mesh grid lines?

Thanks in advance,
Erik
Erik de Boer
2010-12-28 16:28:20 UTC
Permalink
Post by Erik de Boer
Hello,
A surface that I am plotting is difficult to comprehend without its grid lines. At the same time I like to smooth the color shading because some parts of the plot otherwise appear 'patched'.
To smooth the shading I use 'shading interp'. This function does away with the grid lines. I wasn't able to restore the grid lines, for example by adding 'grid on'.
Is there any way to smooth shading in a surf plot without losing the mesh grid lines?
Thanks in advance,
Erik
'grid on' off course refers to grid lines on the axes.
I am referring to mesh grid lines on the surface plot.

Sorry for the confusion.
John D'Errico
2010-12-28 17:21:05 UTC
Permalink
Post by Erik de Boer
Hello,
A surface that I am plotting is difficult to comprehend without its grid lines. At the same time I like to smooth the color shading because some parts of the plot otherwise appear 'patched'.
To smooth the shading I use 'shading interp'. This function does away with the grid lines. I wasn't able to restore the grid lines, for example by adding 'grid on'.
Is there any way to smooth shading in a surf plot without losing the mesh grid lines?
Thanks in advance,
Erik
Given the surface handle, do something like this...

h = surf(stuff);
shading interp
set(h','edgecolor','k')

Thus h is the handle to your surface.

You could also have set the edgecolor directly in the
call to surf, patch, etc.

HTH,
John
Erik de Boer
2010-12-28 19:07:04 UTC
Permalink
Dear John,

Thank you, it works perfectly now.

An edgecolor that is set directly like this "surf(X,Y,beta_q2,'edgecolor','black')" seems to be overruled by the 'shading interp' option, btw.

Regards,
Erik
John D'Errico
2010-12-28 20:31:07 UTC
Permalink
Post by Erik de Boer
Dear John,
Thank you, it works perfectly now.
An edgecolor that is set directly like this "surf(X,Y,beta_q2,'edgecolor','black')" seems to be overruled by the 'shading interp' option, btw.
Yes, if you afterwards set the shading to interpolated,
that will happen. However, why not do this?

surf(X,Y,beta_q2,'edgecolor','k','facecolor','interp')

Now the edges are NOT reset.

You can find all of this by looking at the properties.

John

Loading...