如何在Matlab和Subaxis中缩小子图周围的边界不起作用 [英] How to reduce the borders around subplots in matlab AND subaxis doesn't work

查看:194
本文介绍了如何在Matlab和Subaxis中缩小子图周围的边界不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个GUI,它提供了一个大小可变的matlab子图,我正在寻找一种通用方法将子图挤压在一起.子轴可用于垂直间距,但不会影响水平间距.

I've written a GUI that gives a matlab subplot of varying size and I'm looking for a generic way to squeeze the subplots together. Subaxis works for the vertical spacing, but it doesn't affect the horizontal spacing.

将它们挤压在一起的最简单方法是什么? 输出图形之一的示例,它是通过以下代码在for循环中生成的

What's the simplest way to squeeze them together? An example of one of the output figures it was produced with the following code in a for loop

 subaxis (1+ceil(max(zindex)/5),5,5+i, 'Padding', 0, 'Margin', 0,'SpacingHoriz',0.0001,'SpacingVert',0.009);

推荐答案

看起来您的图形尺寸与您拥有的绘图数量有很大不同.如果您定义图形尺寸,则子轴效果最佳,并且应根据您拥有的图形数来选择宽高比.

It looks like your figure dimensions are way different than the number of plots you have. Subaxis works best if you define your figure size, and you should pick the aspect ratio based on how many plots you have.

在此示例中,您有13 x 5个子图,但是图形的长宽比更像是7:13.因此,垂直图靠近在一起,但是水平空白很大.

in the example you have 13 x 5 subplots, but your figure's aspect ratio is more like 7:13. Hence the vertical plots are close together but there is much horizontal white space.

在绘制之前,尝试定义您的图形,如下所示:

Before plotting, try defining your figure like:

nRows=13;
nCols=5;
PlotWidth=3;  %This is your Plot width in cm. 
FigW=nCols*FigWidth;
FigH=nRows*FigWidth;   %Note: I'm assuming the plots are square
Figure1=figure(1);clf;
set(Figure1,'PaperUnits','centimeters',...
      'PaperSize',[FigW FigH],...
      'PaperPosition',[0,0,FigW,FigH],...
      'Units','centimeters','Position',[1,9,FigW,FigH]);

,看看您的图形间距看起来是否更好.一些注意事项,如果您想使用英寸"而不是厘米,那就很好了.此外,我的图纸上没有任何边距(定义纸张尺寸和纸张位置对于导出很有用).如果您想赚取利润,可以尝试以下方法:

and see if your figure spacing looks better. A few notes, if you want to use 'inches' instead of cm that's fine. Also, I don't have any margins on my paper plot (defining the paper-size and paper position is useful for exporting). If you wanted a margin you might try something like:

Mgn=1;
set(Figure1,'PaperUnits','centimeters',...
      'PaperSize',[FigW+2*Mgn FigH+2*Mgn],...
      'PaperPosition',[Mgn,Mgn,FigW,FigH],...
      'Units','centimeters','Position',[1,9,FigW,FigH]);

然后,您可以使用matlab的 print 命令将其导出为您的选择.

You can then export using matlab's print command to the format of your choice.

这篇关于如何在Matlab和Subaxis中缩小子图周围的边界不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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