如何在Matlab中设置子图的位置 [英] How to set position of subplot in matlab

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

问题描述

我尝试一个接一个地设置此子图,但是无法更改其位置.我该怎么办?

I try to set this subplot one after another, But cannot change their position. What can i do?

figure
subplot(10,1,1,'Position',[0.5,0.69,1,0.1]);plot(B{1, 1}(:,[1,3]),'Color', 
[0,0,0]);legend('Black');
subplot(10,1,2,'Position',[0.5,0.37,1,0.1]);plot(B{2, 1}(:,[1,3]),'Color', 
[1,0,0]);legend('Red');
subplot(10,1,3,'Position',[0,0,1,0.1]);plot(B{3, 1}(:,[1,3]),'Color', 
[0,1,0]);legend('Lime');
subplot(10,1,4,'Position',[0,0,1,0.1]);plot(B{4, 1}(:,[1,3]),'Color', 
[0,0,1]);legend('Blue');
subplot(10,1,5,'Position',[0,0,1,0.1]);plot(B{5, 1}(:,[1,3]),'Color', 
[0,1,1]);legend('Cyan');
subplot(10,1,6,'Position',[0,0,1,0.1]);plot(B{6, 1}(:,[1,3]),'Color', 
[1,0,1]);legend('Magenta');
subplot(10,1,7,'Position',[0,0,1,0.1]);plot(B{7, 1}(:,[1,3]),'Color', 
[0.5,0.5,0.5]);legend('Gray');
subplot(10,1,8,'Position',[0,0,1,0.1]);plot(B{8, 1}(:,[1,3]),'Color', 
[0.5,0,0]);legend('Maroon');
subplot(10,1,9,'Position',[0,0,1,0.1]);plot(B{9, 1}(:,[1,3]),'Color', 
[0.5,0,0.5]);legend('Purple');
subplot(10,1,10,'Position',[0,0,1,0.1]);plot(B{10, 1}(:,[1,3]),'Color', 
[0,0.5,0.5]);legend('Teal');

推荐答案

好吧,只要正确执行操作,就可以更改位置.

Well, you can change the position, as long as you do it properly.

子图手册所述,您可以指定位置:

As stated in the manual of the subplot, you can specify the position:

  • 自动

使用

subplot(m,n,p)

使用m x np位置绘制的网格.这是您部分使用的东西.

Which uses the m x n grid plotting in the p position. This is what you partially used.

  • 手动

通过使用

subplot('Position',[left bottom width height])      

这是您遇到的问题.如手册中所述,如果重叠,则会删除下图. 在您的情况下,有些职位是重叠的.
另请注意,位置始终是规范化的,因此left=0.5width=1表示您在x方向上裁剪了图形的一半.使用手动定位时请注意.
正如 Cris Luengo的答案指出的那样,您可以直接使用axis.其中有一些优点和缺点.但是,axis中的单位也已标准化.因此,知道您在使用什么.

And this is where you have a problem. As it states in the manual, if it overlap, it will erase the graph that is under. In your case, several of the positions are overlapping.
Note also that the positions are always normalized, so left=0.5 with a width=1 means that you cropped half of the figure in the x direction. Pay attention when you use manual positioning.
As Cris Luengo's answer pointed out, you can use axis directly. Which has a few pros and cons. However the unit in axis are also normalized. So, know what you are using.

当您同时使用(手动和自动)设置时,我不清楚哪个将具有首选项,因为当我测试部分代码时,我得到了不同的输出.

When you use both (manual and automatic) settings, it is not clear to me which one will have preferences, as i got different outputs when i tested a part of your code.

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

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