如何在Octave中将两个以上的函数绘制到具有不同范围的同一图表上?

时间:2017-05-09 17:36:09

标签: matlab octave

我找不到任何关于如何在互联网上执行此操作的信息,除了使用仅似乎适用于两个功能的plotyy。

2 个答案:

答案 0 :(得分:2)

来自Matlab文档:

  

对两个数据集使用右y轴

     

使用具有两个y轴的图形绘制三个数据集。绘制一套   与左y轴相关的数据。绘制两组相关的数据   通过使用双列矩阵使用正确的y轴。

x = linspace(0,10);
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
y3 = 0.2*exp(-0.5*x).*sin(10*x);

plotyy(x,y1,[x',x'],[y2',y3']);

答案 1 :(得分:1)

在我看来,赋予最多手动控制权的方法是使用您需要的图创建三个重叠axes,并仅显示最顶层的轴。你甚至可以创造空的'轴只是为了让它们成为唯一具有定义限制的轴。在x和y轴上。

示例:

ax1 = axes();
X1 = linspace(0,8*pi, 100);   Y1 = sin(X1);
plot(X1, Y1, 'r', 'linewidth', 10);

ax2 = axes();
h = ezplot(@(x) x .* sin(x), [-100, 100]); set(h, 'color', 'w');

ax3 = axes();
image()

%% place them on top of each other by calling them in the order you want
axes(ax3); % bottommost
axes(ax1);
axes(ax2); % topmost

set(ax1, 'visible', 'off');
set(ax2, 'visible', 'off');
set(ax3, 'visible', 'on');  % this is the axes who's limits will show

enter image description here