matlab控制图像的边界(margin),subplot的间距(gap)
来源:互联网 发布:99式特警作训帽淘宝网 编辑:程序博客网 时间:2024/06/11 05:38
使用subplot(row, col, i)
创建的子图,matlab会隐式地调整它们的间距以及它们和整个figure的边距,以达到它所认为的美观或者合理的设置,然而如果我们想根据需求设置合理的间距以及边距,该怎么定制呢?
这里提供一个函数(是在没必要把时间花费在这种繁琐的格式上):
function ha = tight_subplot(Nh, Nw, gap, marg_h, marg_w)% tight_subplot creates "subplot" axes with adjustable gaps and margins%% ha = tight_subplot(Nh, Nw, gap, marg_h, marg_w)%% in: Nh number of axes in hight (vertical direction)% Nw number of axes in width (horizontaldirection)% gap gaps between the axes in normalized units (0...1)% or [gap_h gap_w] for different gaps in height and width % marg_h margins in height in normalized units (0...1)% or [lower upper] for different lower and upper margins % marg_w margins in width in normalized units (0...1)% or [left right] for different left and right margins %% out: ha array of handles of the axes objects% starting from upper left corner, going row-wise as in% going row-wise as in%% Example: ha = tight_subplot(3,2,[.01 .03],[.1 .01],[.01 .01])% for ii = 1:6; axes(ha(ii)); plot(randn(10,ii)); end% set(ha(1:4),'XTickLabel',''); set(ha,'YTickLabel','')% Pekka Kumpulainen 20.6.2010 @tut.fi% Tampere University of Technology / Automation Science and Engineeringif nargin<3; gap = .02; endif nargin<4 || isempty(marg_h); marg_h = .05; endif nargin<5; marg_w = .05; endif numel(gap)==1; gap = [gap gap];endif numel(marg_w)==1; marg_w = [marg_w marg_w];endif numel(marg_h)==1; marg_h = [marg_h marg_h];endaxh = (1-sum(marg_h)-(Nh-1)*gap(1))/Nh; axw = (1-sum(marg_w)-(Nw-1)*gap(2))/Nw;py = 1-marg_h(2)-axh; ha = zeros(Nh*Nw,1);ii = 0;for ih = 1:Nh px = marg_w(1); for ix = 1:Nw ii = ii+1; ha(ii) = axes('Units','normalized', ... 'Position',[px py axw axh], ... 'XTickLabel','', ... 'YTickLabel',''); px = px+axw+gap(2); end py = py-axh-gap(1);end
tight\_subplot(Nh, Nw, gap, marg\_h, marg_w)
我们先来介绍参数的含义:Nh, Nw
用法同subplot(row, col)
表示行数和列数,gap(如[0.01, 0.1])表示子图之间垂直方向和水平方向的间隔,marg_h表示的是全部子图到figure上下边界的距离,marg_w则表示的是全部子图到figure左右边界的距离。
一个实例:
ha = tight_subplot(3,2,[.01 .03],[.1 .01],[.01 .01])for ii = 1:6; axes(ha(ii)); plot(randn(10,ii)); endset(ha(1:4),'XTickLabel',''); set(ha,'YTickLabel','')
如果不是plot绘制的图像,而是imshow()显示的图像信息,使用也是如此,
创建全部子图的句柄,hs = tight_subplot(N, N)
用子图各自的句柄创建各自的坐标轴,axes(hs(i))
在每个坐标轴上显示图像信息,imshow()
Nhs = tight_subplot(N, N, [0.01, 0.01], [0.01, 0.01], [0.01, 0.01]);for i = 1:N*N, axes(hs(i)); imshow(...);end
References
[1] <tight_subplot>
[2] Matlab中控制图像显示边界,subplot间距等
1 0
- matlab控制图像的边界(margin),subplot的间距(gap)
- Matlab中控制图像显示边界,subplot间距等
- Matlab subplot 图像间距调整
- Matlab的SUBPLOT的图像大小调整
- Matlab中怎么调整subplot中子图的间距
- Matlab Tricks(三)—— subplot 的组织
- MATLAB中subplot的用法
- MATLAB中subplot的用法
- MATLAB中subplot的用法
- 元素的边界margin属性
- 类边界(java的访问控制)
- Opencv 中类似matlab的subplot功能
- matlab中subplot函数的功能
- matlab subplot(figure)如何设置使得图像最终显示出来不一样大小
- 一分钟了解“Matlab抹去图像边界的无效像素”
- matlab练习程序(二值图像内外边界跟踪)
- Margin 属性的一些边界情况说明
- MATLAB subplot显示不同尺度图像
- Diving into OpenStack Network Architecture - Part 3 - Routing
- 【分享】兼容各种Linux平台的关闭所有指定名字的进程的命令
- A-B
- C++学习记录一
- Intent Resolving in Android M
- matlab控制图像的边界(margin),subplot的间距(gap)
- 字符统计3
- java中关于集合set类的使用,删除集合中的元素
- IIS6.0建立多个网站
- Extjs4之TreePanel、TreeGrid
- socket初试
- 在war包中寻找文件路径
- MapReduce表连接操作之Map端join
- Debug版和Release版的区别