如何在 Octave 中将两个以上的函数绘制到具有不同范围的同一个图形上?
How do I plot more than two functions onto the same graph with very different ranges in Octave?
除了使用 plotyy 之外,我在 Internet 上找不到有关如何执行此操作的任何信息,它似乎只适用于两个功能。
来自 Matlab 文档:
Use Right y-Axis for Two Data Sets
Plot three data sets using a graph with two y-axes. Plot one set of
data associated with the left y-axis. Plot two sets of data associated
with the right y-axis by using two-column matrices.
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']);
在我看来,最手动控制的方法是创建三个重叠 axes
与您需要的图,并且只显示最上面一个的轴。您甚至可以创建 'empty' 轴,这样您就可以将它们用作唯一在 x 轴和 y 轴上定义了 'limits' 的轴。
示例:
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
除了使用 plotyy 之外,我在 Internet 上找不到有关如何执行此操作的任何信息,它似乎只适用于两个功能。
来自 Matlab 文档:
Use Right y-Axis for Two Data Sets
Plot three data sets using a graph with two y-axes. Plot one set of data associated with the left y-axis. Plot two sets of data associated with the right y-axis by using two-column matrices.
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']);
在我看来,最手动控制的方法是创建三个重叠 axes
与您需要的图,并且只显示最上面一个的轴。您甚至可以创建 'empty' 轴,这样您就可以将它们用作唯一在 x 轴和 y 轴上定义了 'limits' 的轴。
示例:
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