方法/步骤 1 首先,我们创建六条曲线,分两次绘制曲线x = 0 : 0.01 : 4*pi;y1 = sin(x);y2 = cos(x);y3 = 3*cos(x);y4 = cos(x).*sin(x);y5 = cos(x) + sin(x);y6 = cos(x) - 2*sin(x);h1 = plot(x,y1,x,y2,x,y3);hold onh2 = plot(x,y4,x,y5,x,y6);2...
plot(x,sin(x),’r’) 5 用axis([xmin,xmax,ymin,ymax])函数来调整图轴的范围 axis([0,6,-1.5,1]) 6 MATLAB也可对图形加上各种注解与处理:(见上表) xlabel(‘x轴’); % x轴注解 ylabel(‘y轴’); % y轴注解 title(‘余弦函数’); % 图形标题 legend(‘y = cos(x)’); % 图形注解...
颜色: y黄; r红; g绿; b蓝; w白; k黑; m紫; c青. 比如:plot(t,y(:,1),'-o',t,y(:,2),'r') 线宽:'LineWidth',4 (表示线宽4号) 比如:plot(x,y,'^r','LineWidth',4)中 x是向量[0,0],y是向量[x(8),x(24)],就是画点[0,x(8)]与点[0,x(24)]两点间的直线。‘^r’是...
legend 函数 , 传入若干个字符串可变参数 , 系统会按照顺序为若干图形进行标识 ; 如上面的示例中 , 给第一个图形标识 sin(x) , 给第二个图形标识 cos(x) ; 代码示例 : %准备绘图变量 x=0:pi/20:2*pi;y1=sin(x);y2=cos(x);%绘制 sin 曲线,红色+圆圈+虚线%绘制 cos 曲线,绿色+三角+冒号线plo...
plot(x, y1, '--or', x, y2, '^g:'); 1. 2. 3. 4. 5. 6. 7. 8. 执行效果 : 二、legend 函数标注图形 legend 函数 , 传入若干个字符串可变参数 , 系统会按照顺序为若干图形进行标识 ; 如上面的示例中 , 给第一个图形标识 sin(x) , 给第二个图形标识 cos(x) ; ...
plot(x,y21,'b-') xlabel('方向') ylabel('能量') legend('草地','公路') set(legend,'edgecolor','none') legend('boxoff') %legend无边框 %--- subplot(2,2,2);plot(x,y12,'r-') hold on plot(x,y22,'b-') xlabel('方向') ...
% 准备绘图变量 x = 0 : pi / 20 : 2 * pi; y1 = sin(x); y2 = cos(x); % 绘制 sin 曲线, 红色 + 圆圈 + 虚线 % 绘制 cos 曲线, 绿色 + 三角 + 冒号线 plot(x, y1, '--or', x, y2, '^g:'); % 按照顺序标识标识图形 legend('sin(x)', 'cos(x)'); % 添加标题 title...
在作图命令中(plot)给出图例标签; Plot two lines. Specify the legend labels during the plotting commands by setting the DisplayName property to the desired text. Then, add a legend. 画两条线。 通过将DisplayName属性设置为所需文本,在绘图命令期间指定图例标签。 然后,添加一个图例(legend)。
This is one legend for the different lines. I think it is not clear what you want. Is this it? 댓글 수: 1 andrew 2014년 3월 7일 This is my plot I have 2 lines with the same color, I'm wondering how to create a legend representing each line once. 댓글을 달...
plot(x,y21,'b-') xlabel('方向') ylabel('能量') legend('草地','公路') set(legend,'edgecolor','none') legend('boxoff') %legend无边框 %--- subplot(2,2,2);plot(x,y12,'r-') hold on plot(x,y22,'b-') xlabel('方向') ...