如何控制子图周围的边距大小?
我正在使用 subplot 命令绘制 5 x 3 的图,但每个子图周围都有大量的边距。
如何控制它们周围的边距大小?
figure;
for c=1:15
subplot(5,3,c);
imagesc(reshape(image(:,c), 360,480));
colormap gray;
axis image;
end
I'm plotting 5 x 3 plots using subplot command, but there are massive margins around each subplot.
How do I control the margin size around them?
figure;
for c=1:15
subplot(5,3,c);
imagesc(reshape(image(:,c), 360,480));
colormap gray;
axis image;
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
问题是 Matlab 分配每个轴的
position
属性,以便每个图周围都有空间。您可以调整position
属性,也可以获取 subaxis从文件交换中并按照您喜欢的方式设置子图。The problem is that Matlab assigns the
position
property of each axis such that there is space around each plot. You can either adjust theposition
property, or you can get subaxis from the File Exchange and set up the subplots the way you like.看一下坐标区的 LooseInset 和 OuterPosition 属性:
http://undocumentedmatlab.com/blog/axes-looseinset-property/
Take a look at the axes's LooseInset and OuterPosition properties:
http://undocumentedmatlab.com/blog/axes-looseinset-property/
从 MATLAB R2019b 开始,您可以使用 tiledlayout 函数来控制次要情节。
下面的示例展示了如何获取没有平铺间距的子图:
Since MATLAB R2019b you can use tiledlayout function to control the spacing of the subplots.
Here's an example which shows how to obtain subplots without tile spacing:
除了其他答案之外,您还可以尝试 Chad Greene 的 smplot< /a> 来自文件交换。这将产生一个 '小倍数' 图并自动处理 Matlab < 的一些麻烦代码>位置属性。
下面的示例显示了默认的
subplot
行为,分别是轴关闭的smplot
和轴打开的smplot
:In addition to the other answers, you could try Chad Greene's smplot from the FileExchange. This will produce a 'small multiple' plot and automatically deal with some of the hassle of Matlab's
position
property.Example below showing default
subplot
behaviour,smplot
with axis off andsmplot
with axis on, respectively:为了最小化每个子图周围的空白,请运行: [1]
此实现自动执行乔纳斯答案中概述的原则。
[1] https ://www.mathworks.com/help/releases/R2015b/matlab/creating_plots/save-figure-with-minimal-white-space.html
To minimize the white space surrounding each subplot, run: [1]
This implementation automates the principle outlined in Jonas's answer.
[1] https://www.mathworks.com/help/releases/R2015b/matlab/creating_plots/save-figure-with-minimal-white-space.html