Hot to get a filled "contourslice" plot?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I am working with sliced plots of 3D data using "contourslice". I would like to have those contour plots filled just like using "contourf" in 2D. There seems to be no way to do this straight out, but I have identified that those contours are patch objects. I am trying to fill them changing the 'FaceColor', but nothing happens.
Anyone knows how to get those contours filled?
THANKS!
2 comentarios
Laurens Bakker
el 27 de Feb. de 2012
What do you want filled? The contours, the slices, both but with different colours, or something else?
Several properties influence the appearance of the faces of a patch object. Have you taken a look at <http://www.mathworks.nl/help/techdoc/ref/patch_props.html>?
Simon
el 6 de Jun. de 2013
Editada: Simon
el 6 de Jun. de 2013
I also have this problem. Perhaps it is a bug.
patchhandle=contourslice(X,T,Z,Q,[],T(1:5:end),[],[1 1]); set(patchhandle(:),'facecolor',[1 1 1])
The set statement does not fill the patches as expected. I have also played with lighting, etc. to no avail.
What needs to be set to make the patch objects from contourslice visibly filled?
Respuestas (1)
Nick Jacek
el 6 de Ag. de 2021
There is no single function to create the kind of plots you describe, but I've notified the developers that there is desire for one to be added. However, one way to get the same effect is to first use interp3 to interpolate the values of your volumetric data along a particular slice and then create a filled contour plot of the result using contourf. This is shown in the following code snippet:
% Load 3D example data
[x, y, z, v] = flow;
% Find the minimum and maximum x and y coordinates of the data
xmin = min(x(:));
xmax = max(x(:));
ymin = min(y(:));
ymax = max(y(:));
% Calculate the x and y coordinates of 100 by 100 grid of points
[xcoord, ycoord] = meshgrid(linspace(xmin, xmax, 100), ...
linspace(ymin, ymax, 100));
% In the slice we are looking at, the z coordinate of every point is 0
zcoord = zeros(100,100);
% Interpolate the data to find a value for each point in the slice
s = interp3(x, y, z, v, xcoord, ycoord, zcoord);
% Plot the slice with filled contours
contourf(xcoord, ycoord, s);

0 comentarios
Ver también
Categorías
Más información sobre Contour 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!