绘制叠加 MATLAB

发布于 2024-08-11 00:18:42 字数 180 浏览 3 评论 0原文

如何在 MATLAB 中将一个图放置在另一图的角落(或任何位置)?

我的对数数据在图的右上角有很大的空白区域。在空白处,我想覆盖一个较小的图,其中包含该空白处日志图的放大版本(有点像放大视图)。

在你告诉我这是不可能的之前,我想提一下,我已经看到了它的实际应用。如果我的描述不够,请告诉我,我会尽力向您更好地描述。

How do you take one plot and place it in the corner (or anywhere for that matter) of another plot in MATLAB?

I have logarithmic data that has a large white space in the upper right-hand side of the plot. In the white space I would like to overlay a smaller plot containing a zoomed in version of the log plot in that white space (sort of like a magnified view).

Before you tell me it can't be done, I would like to mention that I have seen it in action. If my description is lacking, just let me know and I'll attempt to better describe it to you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰葑 2024-08-18 00:18:42

示例:

x = 1:20;
y = randn(size(x));

plot(x, y,'LineWidth',2)
xlabel('x'), ylabel('y'), title('Plot Title')

h = axes('Position', [.15 .65 .2 .2], 'Layer','top');
bar(x,y), title('Bar Title')
axis(h, 'off', 'tight')

screenshot

An example:

x = 1:20;
y = randn(size(x));

plot(x, y,'LineWidth',2)
xlabel('x'), ylabel('y'), title('Plot Title')

h = axes('Position', [.15 .65 .2 .2], 'Layer','top');
bar(x,y), title('Bar Title')
axis(h, 'off', 'tight')

screenshot

疏忽 2024-08-18 00:18:42

您可以使用axes属性'position''units'并使它们重叠。注意在大轴之后创建小轴或使用 uistack() 函数,这样大轴就不会隐藏小轴。

您不能做的就是使一个轴成为另一个轴的子级(就像 Mathworks 对 legend 所做的那样)。但无论如何你都不需要它。

对于第二个图,您必须使用axesline而不是plothold on

当调整父图形的大小(例如手动最大化)时,单位为'标准化'(默认)允许统一的可调整大小的外观。

You can use axes properties 'position' and 'units' and make them overly. Pay attention to create small axes after big one or use uistack() function so that big does not hide small one.

What you can not do is to make an axes child of another one (like Mathworks do with legend). But you do not need it anyway.

For the second plot you have to use axes and line instead of plot and hold on.

Units as 'normalized' (which is default) allows uniform resizable look when parent figure is being resized (e.g. manually maximized).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文