| 在3D空间中,画多条平行的曲线,用不同的color进行标注。 
 两种方法都挺好的。比如
 patch
 或是
 plot3
 
 
 复制代码clear all
clc
clf
n=6;
% generate color
% col_mm=summer(6);
col_mm=jet(n);
% gen data
x=linspace(1,20,300);
for i=1:n
    z(i,:)=exp(1./x)+0.2*sin(x)+rand(size(x))+1;
end
tm=randperm(n+5);
y=tm(1:n);
% plot each line with patch, 
% hold on
% for i=1:n
%     pl_x=[x(1),x,x(end),x(1)];
%     pl_y=y(i)*ones(length(x)+3,1);
%     pl_z=[0,z(i,:),0,0];
%     patch(pl_x,pl_y,pl_z,...
%         col_mm(i,:),'edgecolor','none');
%     leg_str{i}=['i am ',mat2str(i),' line'];
% end
% 
% view(40,60)
% grid on
% axis tight
% legend(leg_str,'location','southwestoutside')
% h=gcf;
% set(h,'position',[600,200,800,500]);
% 
% 
close all
hold on
for i=1:n
    pl_x=[x];
    pl_y=y(i)*ones(length(x),1);
    pl_z=[z(i,:)];
    plot3(pl_x,pl_y,pl_z,...
       'color',col_mm(i,:));
    leg_str{i}=['i am ',mat2str(i),' line'];
end
view(40,60)
grid on
axis tight
legend(leg_str,'location','southwestoutside')
h=gcf;
set(h,'position',[600,200,800,500]);
 
 |