如何在MATLAB中定位子图? [英] How do I position subplots in MATLAB?

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

问题描述

我在设置子图的位置时遇到问题.我在循环内使用子图.但是,当我尝试对子图进行特殊定位时,这是行不通的.这是我的代码:

I have problem to set the position of subplots. I'm using subplot inside a loop. But when I try to make special position to the subplots it doesn't work. This is my code:

h=subplot(2,2,3);
set(h,'position',[0.15 0.15 0.4 0.4]);
plot(d3,S3,'*','Color',colors(i,:));

我尝试了不同的方法,但看不到第三个子图,有时该图仅显示一个迭代.

I tried different methods but can't see the third subplot, and sometimes the plot shows only one iteration.

我该如何解决?

推荐答案

这将创建3个子图.位置是[左底部宽度高度]).我通常会尝试确保left + width< 1,而底部+高度< 1(对于第一个子图).

This create 3 subplots. Position is [left bottom width height]). I usually try to make sure that left + width < 1 and that bottom + height < 1 (for the first subplot).

figure
set(subplot(3,1,1), 'Position', [0.05, 0.69, 0.92, 0.27])
set(subplot(3,1,2), 'Position', [0.05, 0.37, 0.92, 0.27])
set(subplot(3,1,3), 'Position', [0.05, 0.05, 0.92, 0.27])

如果您只有1列子图,则此方法效果很好.对于两列子图,请使用:

This works well if you only have 1 column of subplot. For two columns of subplot is use this :

figure
subplot(4,2,1)
plot(...)
set(gca, 'OuterPosition', [0, 0.76, 0.49, 0.23])
subplot(4,2,2)
plot(...)
set(gca, 'OuterPosition', [0.48, 0.76, 0.49, 0.23])
subplot(4,2,3)
...

这篇关于如何在MATLAB中定位子图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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