Hot to get a filled "contourslice" plot?

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

Laurens Bakker
Laurens Bakker 2012년 2월 27일
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
Simon 2013년 6월 6일
편집: Simon 2013년 6월 6일
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?

댓글을 달려면 로그인하십시오.

답변 (1개)

Nick Jacek
Nick Jacek 2021년 8월 6일

0 개 추천

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);

카테고리

질문:

2011년 2월 15일

답변:

2021년 8월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by