For 3D surface plots, do you like the command, 'shading interp'?

14 visualizzazioni (ultimi 30 giorni)
Hi there!
For 3D surface plots, do you like the command, 'shading interp'? When I use it, I notice that the color variation on the surface is quite smooth, with the faint lines that typically show the cross sections of the surface not visible anymore. However, I'm not sure that this is a good thing.
Thanks in advance,

Risposte (1)

Star Strider
Star Strider il 6 Gen 2025
There are a few options that you can experiment with —
[X,Y] = ndgrid(-5:0.5:5);
Z = exp(-(X.^2 + Y.^2)/10);
figure
surf(X, Y, Z)
colormap(turbo)
title('Original')
figure
surf(X, Y, Z)
colormap(turbo)
shading('interp')
title('shading(''interp'')')
figure
surf(X, Y, Z, FaceColor='interp')
colormap(turbo)
title('FaceColor=''interp''')
figure
surf(X, Y, Z, EdgeColor='interp')
colormap(turbo)
title('EdgeColor=''interp''')
figure
surf(X, Y, Z, FaceColor='interp', EdgeColor='interp')
colormap(turbo)
title('FaceColor=''interp'', EdgeColor=''interp''')
.
  2 Commenti
Noob
Noob il 8 Gen 2025
Modificato: Noob il 8 Gen 2025
Hi Star Strider,
Did you, by any chance, post this answer going from "worst" to "best", so that using both FaceColor interp and EdgeColor interp is the best way to present color variation on a surface? What exactly is a FaceColor and what is an EdgeColor? Is FaceColor the color along the surface area of the figure, while EdgeColor is the color along the edges of the figure?
If I use all three of these features: EdgeColor interp, FaceColor interp, and shading interp, then I don't see how the color variation on the surface is any different from, say, just using EdgeColor interp.
If I use EdgeColor interp, then I don't see how adding FaceColor interp is helping.
Thanks!
Star Strider
Star Strider il 8 Gen 2025
My pleasure!
They are in no particular order, other than the first two being individual options, and the third both options combined. Both options combined are the equivalent of shading('interp').
Surfaces in MATLAB are collecitions of ‘patches’ (see the patch function documentation for details), and ‘edges’ are the patch outlines (in this context). Interpolating the edge colours does only that, so the edge lines are the colour of the appropriate side of the patch. Interpolating the face colours does exactly that, leaving the edge lines unchanged. Interpolating the edge colours does exactly that, leaving the face colours unchanged. Interpolating both is the same as shading('interp').
‘If I use EdgeColor interp, then I don't see how adding FaceColor interp is helping.
If interpolating the edges is all you want to do, stop there. There is no need to interpolate the face colours if you don’t want to. That’s entirely your decision.
.

Accedi per commentare.

Prodotti


Release

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by