Fill under lines in plot3

조회 수: 4 (최근 30일)
Meva
Meva 2017년 3월 22일
편집: Meva 2017년 3월 23일
Hello,
I need to fill under the Z-data in a plot3. I have below function.
function mmplot3(x,y,z,c,w,b,d)
%MMPLOT3 3-D color-based plot.
% MMPLOT3(X,Y,Z,C,W,B) or MMPLOT3(X,Y,Z,C,W,B,D), where X, Y, Z and C are
% 4 vectors of the same length, plots a line in 3-space through the points
% whose coordinates are the elements of X, Y and Z with colors
defined by
% vector C. W is the width of the line, B is the line brightness while
% solid line plot is used, otherwise it's the marker style and D is the
% indices increment.
x = x(:); y = y(:); z = z(:); c = c(:);
switch b
case {'.','o','x','+','*','s','d','v','^','<','>','p','h'}
iNaN=find(isnan(x));
if isempty(iNaN), iNaN = length(x); end
i = [1:d:iNaN(1),iNaN(1)];
x = x(i); y = y(i); z = z(i); c = c(i);
scatter3(x,y,z,w,c,b)
otherwise
plot3(x,y,z,'linestyle','none') % make a blank plot
surface([x, x], [y, y], [z, z], ...
[c, c], 'EdgeColor','flat', 'FaceColor','none', 'linewidth',w, 'EdgeAlpha',b)
end
Please see attached. The 3d plot I have (on the right hand side attached) is quite is unclear, not like the figure on left hand side.
I need to fill under the Z data with white color.
Also associate each Z-data with each time (X-data) in the plot.
  댓글 수: 4
KSSV
KSSV 2017년 3월 23일
You have not mentioned inputs....x,y,z
Meva
Meva 2017년 3월 23일
편집: Meva 2017년 3월 23일
Thanks KSSV. Please see attached file. On the left hand side there is a clear figure which is I would like to obtain. The figure on the right hand side is what I have obtained. Please ignore the difference between data. I just would like to have the same appearance.
The above code is a nested function. The main m file has
figure(1)
colormap hsv
for kt = 1 : tstep : nr
mmplot3(t(kt,:), x2(kt,:), p(kt,:), p(kt,:), 1, 0.5)
hold on
end
%%%%following part is to fill but it does not work!
vert = [t0 0 p(1,1);t0 0 -0.6;t0 1 -0.6;t0 1 p(1,nc)];
fac = [1 2 3 4]
patch('Vertices',vert,'Faces',fac,...
'FaceVertexCData',white(1),'FaceColor','flat')
So, in the main code these are
t1 = t0 : dt : tfinal;
x1 = x0 : dx : xfinal;
[x2,t]=meshgrid(x1,t1);
[nr,nc]=size(x2);
p = zeros(nr,nc);
where
t0=0.1;
tfinal = 1;
dt = 0.0001; % step size
x0 = 0;
xfinal = 1;
dx = 0.001; % step size
% tstep = 9900; % time step for 3D plot
tstep=900;

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by