Code covered by the BSD License  

Highlights from

5.0 | 5 ratings Rate this file 45 Downloads (last 30 days) File Size: 3.91 KB File ID: #38581



Brendan (view profile)


11 Oct 2012 (Updated )

MATLAB function for tiling figures on the screen.

| Watch this File

File Information

Inspired by , but with a number of improvements. User can choose which figures to tile, can resize or not, can specify a number of rows and/or columns, can specify a spacing between the figures, and can specify a sub-portion of the monitor to be used.

tilefigs also allows tiling on a dual monitor, though MATLAB does not (at present) officially support multiple monitors, and so some manual effort may be required.

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
22 Oct 2014 eduardo Schenberg

i love this function, but all of a sudden now I got the following error (which I can not understand nor solve):

Error using set
Width and height must be > 0
Error in tilefigs (line 169)
set(handles(pnum),'OuterPosition',[xLocation yLocation width height]);

I appreciate any help! working in matlab R2013b ( in mac OS 10.9.4


Comment only
16 Oct 2014 Peter Pablo  
15 May 2014 alejandro castro

Works very well as described on my linux machine.

12 Dec 2013 Rico

Rico (view profile)

Thanks for this nice function!

There is one problem, though, when you are running matlab in linux. In this case 'MonitorPositions' has a different meaning (see

Thus, linux users need to replace

matlabMonitorSize = monitorPositions(:,3:4) - monitorPositions(:,1:2) + 1;


matlabMonitorSize = monitorPositions(:,3:4);

Comment only
12 Sep 2013 Jonathan

I love this function, it is very useful and works well.

My only issue is that (as you describe in the comments) it does not correctly position the figures on multi-monitor setups. This is because get(0,'MonitorPositions') returns the monitor boundaries in 'display' coordinates with (1,1) at the upper left corner of monitor 1, while figure positions start at the lower left corner.

If you replace your definition of 'matlabMonitorLocation' with:
matlabMonitorLocation = [monitorPositions(:,1) (monitorPositions(1,4) - monitorPositions(:,4) + 1)];

it works perfectly (at least on my 4 monitor Windows 7 setup on MATLAB R2013a).

02 Jun 2013 Brendan

Brendan (view profile)

Anne, to fix the fact that the images don't go all the way down the screen, you can edit the default border.

% Set the default border if none is specified [left, bottom, right, top]
if monitor > 1
if ~exist('border','var') || isempty(border)
border = [0 0 0 0];
if ~exist('border','var') || isempty(border)
border = [0 30 0 0];

Change the second border to [0 0 0 0]

Are you setting resize to false? If not, I don't understand the issue with the figure overlap. Tilefigs uses the "outer position" information from the figure handle, so either there is an error in my math somewhere, or matlab does not compute the outer position of the figures properly. A hack to fix this would be to add in a leftRightSpacing ( or topBottomSpacing), though I agree it's not ideal.

Comment only
02 Jun 2013 Anne

Anne (view profile)

Great function—thank you for sharing it!

The only issue for me (I'm on Mac OS 10.6.8) is that there is some overlap between the windows, and they don't go quite all the way down to the bottom of the screen. But that's a very minor thing—otherwise it works great.

15 May 2013 Alexandre Willame

Awesome function! I now use it a nearly all my simulations. You can very easily sort your figure just by doing (for example):

h(1) = figure();
h(2) = figure();
h(3) = figure();
h(4) = figure();
h(5) = figure();


And that's it! All your figures are placed correctly on the screen so you can analyse easily and conveniently all your results. A must have.

05 Dec 2012 Brendan

Brendan (view profile)

Updated to allow for non-pixel units for figures

Comment only
05 Dec 2012

Changed to allow arbitrary figure units (instead of forcing pixels)

Contact us