matlab size命令,关于subplot size 定义大小

本帖最后由 meatball1982 于 2016-10-29 08:52 编辑

好长时间了,终于通过ax 的position设置来解决了。

clear all

clc

clf

sbp_width=0.8;

sbp_heig=0.85;

n_row = 4;

n_col = 6;

[out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);

h=figure(1)

set(h, 'Position', [100, 100, 800, 600]);

[x,y,z]=peaks(30);

caxis_mm=[-5 30];

for i=1:n_row*n_col

ax=axes('position',out_pos(i,:));

surf(x,y,z+i,'edgecolor','none')

caxis(caxis_mm)

axis tight

view(0,90)

hold on

text([1],[2],[30],mat2str(i),'fontsize',20)

end

colormap(jet)

function [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);

% subplot pos

% input : -----------------

% n_row     : number of row

% n_col     : number of column

% sbp_width : subplot width  0-1

% sbp_heig  : subplot height 0-1

% output : ----------------

% out_pos

%

%

% sbp_width=0.8;

% sbp_heig=0.85;

% n_row = 4;

% n_col = 6;

% [out_pos]=fun_mm_subplot_pos(n_row,n_col,sbp_width,sbp_heig);

% h=figure(1)

% set(h, 'Position', [100, 100, 800, 600]);

% [x,y,z]=peaks(30);

% caxis_mm=[-5 30];

% for i=1:n_row*n_col

%     ax=axes('position',out_pos(i,:));

%     surf(x,y,z+i,'edgecolor','none')

%     caxis(caxis_mm)

%     view(0,90)

%     hold on

%     text([2],[2],[30],mat2str(i),'fontsize',20)

% end

for i=1:n_row*n_col

k1=ceil(i/n_col);

k2=i-(k1-1)*n_col;

out_pos(i,:)=[(1-sbp_width)/n_col/2 + (k2-1)/n_col,...

(1-sbp_heig )/n_row/2 + (n_row-k1)/n_row, ...

sbp_width/n_col,...

sbp_heig/n_row];

end

2016-10-29 08:52 上传

442a53943febe9465fc072b4fbe10813.gif

b2a5a3e0dcc7d508e00275fe42fce1b5.gif

47e5f1db2cfcdf0d70e61ff5e3d8dea0.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值