如何在Matlab中绘制彼此上方的图形? [英] How to plot graphs above each other in Matlab?

查看:20
本文介绍了如何在Matlab中绘制彼此上方的图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Matlab 中绘制两个(或更多)图形.我希望它们在第三个上方的第二个上方对齐,依此类推.但是子情节对我来说不是这样.我也不希望它们以不同的颜色出现在同一张图上,只是一个在另一个之上.是否可以?我正在寻找这样的命令,但没有任何成功.提前感谢您的提示!

I want to plot two (or more) graphs in Matlab. I want them to be aligned one above the second one above the third and so on. However subplot is not the case for me. I also don't want them both to be on the same graph in different colors, just to be one above the other. Is it possible? I'm searching for such a command but without any success. Thanks in advance for hints!

推荐答案

如果你所说的一个在另一个之上"是一个在另一个之上",那么我认为你需要使用的是 命令.话虽如此,为了让你的情节可读,我认为在同一个情节中超过两个比例会使阅读变得非常困难.

If what you mean by "one above the other" is one "on top of another" then I think what You need to use is the axes command. Having said that, in order to have your plot be readable, I think more than two scales in the same plot makes it pretty hard to read.

这个 Matlab的帮助页面告诉你怎么做它的要点显示在以下脚本中:

This Matlab's help page shows you how to do it, the gist of it is shown in the following script:

y2 = 1000.*rand(100,1);
x2 = 0:99;

% Plot the first data set
hl1 = line(x1,y1,'Color','r');
% Get the axes and configure it
ax1 = gca;
set(ax1,'XColor','r','YColor','r')

%Create the new axes
ax2 = axes('Position',get(ax1,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none',...
           'XColor','k','YColor','k');
% Plot the second data set with the new axes
hl2 = line(x2,y2,'Color','k','Parent',ax2);

上述脚本创建了以下 plot,其中一组轴为红色和另一个黑色.

The above script creates the following plot with one set of axes in red and another in black.

希望这会有所帮助.

这篇关于如何在Matlab中绘制彼此上方的图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆