File Exchange

image thumbnail


version 1.1 (3.91 KB) by

MATLAB function for tiling figures on the screen.



View License

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.

Comments and Ratings (13)

Wonderful function, thanks a lot!
However, I made the following mod in the final lines to avoid a crash if there is only one figure present:

% This part was modified on March 21, 2017 by Kristoffer Kjærnes. 'units' is
% not a cell array if there is only one figure present. This mod prevents a
% crash.
if nFigures == 1
for ii = 1:nFigures


By the way, John Smith's comment 20 Feb 2016 seems appropriate to implement as well.

John Smith

Great utility!
There's a problem, though:
The program changes figure units to 'pixels' while running and reverts back to whatever units the figure had.
However, since the units were changed from 'normalized', resizing of the figure does not resize text, labels, etc. Therefore, they get clipped.
It'd much better to operate with 'normalized' units.


Arnold (view profile)

Thank you!! Pico's suggestion also works great on my linux machine.

Thanks for a great function!
Note - For those who are in search of a function which is optimized for tiling figures of different sizes, you might want to try my arrangeFigures

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


Peter Pablo

Works very well as described on my linux machine.


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);


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).


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.


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.

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.


Brendan (view profile)

Updated to allow for non-pixel units for figures



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

MATLAB Release
MATLAB 7.12 (R2011a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today