Version 2 (modified by 12 years ago) ( diff ) | ,
---|
Matlab Scripts
Create Array of SubPlots
This script allows tilings of subplots with user controlled padding and margins (includes an optional colorbar)
figure(1) clf % All measurements are scaled to window width or height lbuffer=.075; %left margin rbuffer=.075; %right margin tbuffer=.075; %top margin bbuffer=.075; %bottom margin colorbarwidth=.03; %colorbar width - Set to 0 for no colorbar paddingx=.05; % x padding between subplots paddingy=.05; % y padding between subplots nx=4; % number of subplots in x ny=3; % number of subplots in y (not counting colorbar) if (colorbarwidth==0) % no color bar figure_width=(1-lbuffer-rbuffer-(nx-1)*paddingx)/nx; else figure_width=(1-lbuffer-rbuffer-colorbarwidth-(nx)*paddingx)/nx; end figure_height=(1-tbuffer-bbuffer-(ny-1)*paddingy)/ny; deltax=figure_width+paddingx; deltay=figure_height+paddingy; y=bbuffer; for j=1:ny x=lbuffer; for i=1:nx subplot('position',[x,y,figure_width,figure_height]) %--------------------------------------------------------- %replace this plotting code with your plot routine imagesc(rand(20)) %-------------------------------------------------------- x=x+deltax; end y=y+deltay; end if (colorbarwidth > 0) colorbar('position',[lbuffer+nx*deltax,bbuffer,colorbarwidth,ny*deltay-paddingy]) colormap(gray) end
Note:
See TracWiki
for help on using the wiki.