Fill under lines in plot3

4 vues (au cours des 30 derniers jours)
Meva
Meva le 22 Mar 2017
Modifié(e) : Meva le 23 Mar 2017
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 commentaires
KSSV
KSSV le 23 Mar 2017
You have not mentioned inputs....x,y,z
Meva
Meva le 23 Mar 2017
Modifié(e) : Meva le 23 Mar 2017
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;

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by