example_plotyy.m

来自「基础程序」· M 代码 · 共 19 行

M
19
字号
% example_plotyy.m
% 使用plotyy函数绘制双坐标轴图像
x1=-2.9:0.2:2.9;
y1=exp(-x1.*x1);
x2=-2.9:0.05:2.9;
y2=sin(3*x2);
[AX,H1,H2] = plotyy(x1,y1,x2,y2,'bar','plot');
title('figure1: plotyy in default');
% 通过句柄函数改变属性
% 添加纵坐标轴名称
figure(2);
[AX,H1,H2] = plotyy(x1,y1,x2,y2,'bar','plot');
set(get(AX(1),'Ylabel'),'String','y1=exp(-x.*x)');
set(get(AX(2),'Ylabel'),'String','y2=sin(3*x)');
% 改变线型属性
set(H1,'barwidth',0.6,'edgecolor',[1 0 0],'facecolor',[1 1 0.4745]);
set(H2,'linewidth',1,'marker','*')
title('figure2: plotyy after change');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?