一、plot 函数绘制多个图形 二、legend 函数标注图形 三、图形修饰 一、plot 函数绘制多个图形 使用单个 plot 函数绘制多条曲线 : plot 函数可以传入多个可变参数 , 三个变量一组 , 每一组中 ; 第一个变量是 x 轴向量 ; 第二个变量是 y 轴向量 ; 第三个变量是 线条设定字符串 ; 代码示例 : 代码语言:...
例如,title('My Plot')、xlabel('X Axis') 和ylabel('Y Axis')。 图例(Legend):使用 legend 函数可以在图表中添加图例,以标识不同的数据系列。例如,legend('Series 1', 'Series 2')。 网格线(Grid Lines):使用 grid on 或grid off 命令可以显示或隐藏网格线。 轴范围(Axis Limits):使用 xlim 和ylim ...
在绘制曲线之后,可以使用变量来标记每个数据系列,并使用这些变量作为legend函数的输入。例如,使用上述的曲线数据,您可以使用以下代码创建图例: x = 1:10; y1 = 2*x; y2 = 3*x; plot(x, y1, 'r'); hold on; plot(x, y2, 'b'); legend('Data 1', 'Data 2'); 复制代码 注意,这里我们使用了h...
要进一步分别图像,我们需要给图像添加Legend,还要给整个图像命名,具体代码如下:To further separate the images, we need to add Legend to the image and also name the entire image as per the following code:x=0:0.1:5*pi y1=sin(x)y2=cos(x)plot(x,y1,'xr--',x,y2,'og:')legend('sin(...
x = 1:10; y1 = x; y2 = x.^2; y3 = x.^3; plot(x, y1, 'r', 'DisplayName', 'y = x'); hold on; plot(x, y2, 'g', 'DisplayName', 'y = x^2'); plot(x, y3, 'b', 'DisplayName', 'y = x^3'); hold off; legend('Location', 'northwest'); 复制代码 运行上述...
Today, the editor brings the “Matlab drawing of legend”. Welcome your visit! The reading time of this tweet is about 5 minutes. Please be patient. 1、创建图像 1.Create an image 创建函数图像一般用plot函数,二维用plot,三维则用plot3,在matlab中,函数有很多,最简单的莫过于sinx和cosx,他两的图...
方法/步骤 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,y2,'og:'); hold off 3. 添加Legend和Title Add Legend and Title 要进一步分别图像,我们需要给图像添加Legend,还要给整个图像命名,具体代码如下:To further separate the images, we need to add Legend to the image and also name the entire image as per the following code: x=0:0.1:5*pi...
plot(x, y1, '--or', x, y2, '^g:'); % 按照顺序标识标识图形 legend('sin(x)', 'cos(x)'); 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 执行结果 : 三、图形修饰 图形修饰 : 添加标题 : title()
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('方向') ...