Fill under lines in plot3

7 views (last 30 days)
Meva on 22 Mar 2017
Edited: Meva on 23 Mar 2017
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'}
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);
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)
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.
Meva on 23 Mar 2017
Edited: Meva on 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
colormap hsv
for kt = 1 : tstep : nr
mmplot3(t(kt,:), x2(kt,:), p(kt,:), p(kt,:), 1, 0.5)
hold on
%%%%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]
So, in the main code these are
t1 = t0 : dt : tfinal;
x1 = x0 : dx : xfinal;
p = zeros(nr,nc);
tfinal = 1;
dt = 0.0001; % step size
x0 = 0;
xfinal = 1;
dx = 0.001; % step size
% tstep = 9900; % time step for 3D plot

Sign in to comment.

Answers (0)


Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!