1、绘制多条曲线
x = 0:pi/100:2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);
y4 =sin(x-0.75);
y5 = sin(x-1);
y6 = sin(x-1.25);
y7 = sin(x-1.5);
y8 =sin(x-1.75);
figure
plot(x,y1,'y');hold on;
plot(x,y2,'m');hold on;
plot(x,y3,'c');hold on;
plot(x,y4,'r');hold on;
plot(x,y5,'g');hold on;
plot(x,y6,'b');hold on;
plot(x,y7,'k');hold on;
plot(x,y8,'k');hold on;
文章来源:https://www.toymoban.com/news/detail-521049.html
2、给其中几条曲线添加图例
x = 0:pi/100:2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);
y4 =sin(x-0.75);
y5 = sin(x-1);
y6 = sin(x-1.25);
y7 = sin(x-1.5);
y8 =sin(x-1.75);
figure
plot(x,y1,'y');hold on;
plot(x,y2,'m');hold on;
h1=plot(x,y3,'c');hold on;
plot(x,y4,'r');hold on;
h2=plot(x,y5,'g');hold on;
plot(x,y6,'b');hold on;
h3=plot(x,y7,'k');hold on;
plot(x,y8,'k');hold on;
legend([h1,h2,h3],'曲线1','曲线2','曲线3')
文章来源地址https://www.toymoban.com/news/detail-521049.html
到了这里,关于Matlab多条曲线标注某几条曲线的图例 (legend函数)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!