城市网

plotyy怎么设置纵坐标标注(plotyy)

导读 大家好,小城来为大家解答以上问题。plotyy怎么设置纵坐标标注,plotyy很多人还不知道,现在让我们一起来看看吧!1、plotyy函数,用于在一...

大家好,小城来为大家解答以上问题。plotyy怎么设置纵坐标标注,plotyy很多人还不知道,现在让我们一起来看看吧!

1、plotyy函数,用于在一个图中绘制多条2D图形的一个非常常用的函数。有多种格式,下面将给出一般的使用规范。

2、用两个y轴绘制两个图像

3、x = 0:0.01:20;

4、y1 = 200*exp(-0.05*x).*sin(x);

5、y2 = 0.8*exp(-0.5*x).*sin(10*x);

6、figure % new figure

7、plotyy(x,y1,x,y2)

8、增加标题和y轴标签

9、x = 0:0.01:20;

10、y1 = 200*exp(-0.05*x).*sin(x);

11、y2 = 0.8*exp(-0.5*x).*sin(10*x);

12、figure % new

13、figure[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);

14、title('Multiple Decay Rates')

15、xlabel('Time (\musec)')

16、ylabel(hAx(1),'Slow Decay') % left y-axisylabel(hAx(2),'Fast Decay') % right y-axis

17、更改线型

18、x = 0:0.01:20;

19、y1 = 200*exp(-0.05*x).*sin(x);

20、y2 = 0.8*exp(-0.5*x).*sin(10*x);

21、[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);

22、hLine1.LineStyle = '--';

23、hLine2.LineStyle = ':';

24、将两种不同的线型绘制在一起

25、x = 0:0.1:10;

26、y1 = 200*exp(-0.05*x).*sin(x);

27、y2 = 0.8*exp(-0.5*x).*sin(10*x);

28、figure

29、plotyy(x,y1,x,y2,'plot','stem')

30、使用带有两个y轴的图绘制三组数据。 绘制与左侧y轴相关的一组数据。 通过使用两列矩阵绘制与右侧y轴相关联的两组数据。

31、x = linspace(0,10);

32、y1 = 200*exp(-0.05*x).*sin(x);

33、y2 = 0.8*exp(-0.5*x).*sin(10*x);

34、y3 = 0.2*exp(-0.5*x).*sin(10*x);

35、figure

36、[hAx,hLine1,hLine2] = plotyy(x,y1,[x',x'],[y2',y3']);

本文到此结束,希望对大家有所帮助。