How do I make a mesh or surface plot that is clear in certain places?

25 visualizaciones (últimos 30 días)
I want to create a SURF or MESH plot but would like the surface to have empty regions or holes in specific places.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 24 de Mayo de 2013
If the surface or mesh data has a NaN (not-a-number) in it, then the location of the NaN will be blank (just as NaNs in 2-d plots leave blanks). The example below illustrates using NaNs to make certain parts of a plot transparent.
%Generate a SURF plot with peaks data
z = peaks;
surf(z)
%Change peaks data so that a portion of that matix is made up of NaNs
m = z;
m(15:30,15:30) = nan;
%Plot the new matrix, m where the x and y information consisting of NaNs
%represents a hole in the SURF plot
figure;
surf(m)
As of MATLAB 6.0 (R12) you can use transparency to set a face to be transparent.

Más respuestas (0)

Categorías

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

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by