5.0 | 6 ratings Rate this file 41 Downloads (last 30 days) File Size: 63 KB File ID: #37176
image thumbnail

Distribute figures



15 Jun 2012 (Updated )

This function can distribute all open figures on different parts of the screen(s).

| Watch this File

File Information

Are you tired of moving your figures around to see them all? This function does it all for you. It can distribute in all parts of the screen, include Simulink figures or not and a whole lot more! It also supports secondary monitor(s) where the figures can be distributed.
>>>> A sample image can be found here: http://i58.tinypic.com/wjidk6.png <<<<<

The function calls needed to distribute in the shown pattern above is only:

distFig('Pos','NW' , 'Only',1);
distFig('Pos','SW' , 'Only',[2,3,4] , 'Cols', 3);
distFig('Pos','NE' , 'Rows',2 , 'Only', [5,6]);
distFig('Pos','SE' , 'Cols',4 , 'Not', (1:6));

The function supports all resolutions. It has been made using Matlab 2015a (Prerelease) and will thus not work properly for version 2014a and previous due to the changes in the figure handle system in the newer releases.

The function should work for all resolutions (also different resolutions on different monitors and different monitor positions).







distFig(...,'Screen',Value) assigns where the figures will be
Synonums for 'Screen' are 'Scr'. Value can be:
'C' / 'Center' (Default)
'W' / 'West' / 'L' / 'Left'
'E' / 'East' / 'R' / 'Right'
'N' / 'North' / 'T' / 'Top'
'S' / 'South' / 'B' / 'Bottom'
'Main' / 'Primary'
'Ext' / 'External' / 'Secondary'

distFig(...,'Position',Value) assigns in which part of the screen the
figures will be distributed.
Synonums for 'Position' are 'Pos'. Value can be:
'C' / 'Center' (Default)
'W' / 'West' / 'L' / 'Left'
'E' / 'East' / 'R' / 'Right'
'N' / 'North' / 'T' / 'Top'
'S' / 'South' / 'B' / 'Bottom'

distFig(...,'Rows',Value) assigns how many rows the figures will be
distributed on.
Synonums for 'Rows' are 'R'. Value can be:
'Auto' / -1
'Auto' indicates that it automatically calculates the number of required

distFig(...,'Columns',Value) assigns how many rows the figures will be
distributed on.
Synonums for 'Columns' are 'Cols'. Value can be:
'Auto' / -1
'Auto' indicates that it automatically calculates the number of required

distFig(...,'Not',Value) excludes specified figures from the distribution
list. Value must be an array with the excluded figure numbers. The
default value is [].

distFig(...,'Only',Value) does only distrubute specified figures. Value
must be an array with the figure which will be destributed. The
default value is [].

The remaining options are described in the file.

Required Products MATLAB
MATLAB release MATLAB 8.4 (R2014b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (16)
22 Oct 2014 Anders Simonsen

@Mike: Thanks - so do I. ;)

Okay, thanks for the feedback and for finding and fixing the problem! :D I'll make sure to include it in the next version of it.

I've also stumbled upon a few bugs as well, which aren't working properly after the 2014b release, so I'll update it again soon.

22 Oct 2014 Mike

Very nice feature, I use it all the time :)

Had a little compatibility issue with the newly released R2014b. Since figure handles are no longer numbers but figure objects, the sort feature no longer works. Hence, the figures get distributed nicely, just not in the right order. I fixed this by accessing the Number property of the figure objects instead. (see below)

My code adaptation, first line of 'Generate figure list' section:
Fig_List = findall(0,'type','figure');

Fig_Object = findall(0,'type','figure');
Fig_List = [Fig_Object.Number];

This way, Fig_List is a vector of numbers again that can be sorted a few lines below ;) Not sure if it's the neatest way, but works fine for me :)

07 Sep 2014 Anders Simonsen

@arnold: Can you send me an example code, where you are having the problem? Then I can take a look at it. :) (Btw. I've sent you a private message as well)

04 Sep 2014 arnold

hi anders.
I've integrated the 'tight' argument in many of my functions but just saw that it is cutting off any xlabel one adds to a boxplot... no idea why xlabels of boxplots are treated entirely different than those of other plots.

20 Aug 2014 Anders Simonsen

@arnold: I've just updated it again and now it should work. I didn't test it yesterday on 2014a as I didn't have acces to it, but now I have done that and fixed the error.

It is caused by the new way that the figure system is made in 2014b, which has been changed a lot! The only thing you should do is to download it again or just delete the line that is causing the error. :)

20 Aug 2014 arnold

@ Anders: thanks for the update. Unfortunately the function does not work anymore, no matter what type of figures are open. i.e. opening four figures, no content, then executing 'distFig' with no arguments. Gives the following error on 2014a:

Improper index matrix reference.

Error in distFig>@(n)(Figs(n).Number) (line 199)
Figs = sort(arrayfun(@(n) (Figs(n).Number),1:numel(Figs)));

Error in distFig (line 199)
Figs = sort(arrayfun(@(n) (Figs(n).Number),1:numel(Figs)));

19 Aug 2014 Anders Simonsen

@arnold: I've just updated the function to support the other function. The problem was that "fig()"; changed 'Units' to 'centimeters', whereas my function was using 'pixels'. Furthermore, I've added a new feature called distFig(...,'Tight',true/false), which can remove the whitespace around the figure like "fig();" - if that is what you're looking for. :)

And thanks for the feedback. :)

19 Aug 2014 arnold

for some reason 'distFig' can't deal with figures produced by 'fig' from the fileExchange, which is also a great tool:

The figures disappear from the screen even though they're still opened.

04 Jun 2014 Anders

Often i used to be both tired and depressed - but then I tried Quack Simonsen's mircale function. Now I feel much better - thanks Simonsen!

29 May 2014 Anders Simonsen

@Ivan: Sorry for the late response. Yes - the new function does support different screen resolutions. :)

31 Mar 2014 Ivan

Does it support different screen resolutions? Or just 1920*1080?

29 Nov 2013 Mark Søndergaard Sørensen

Exactly what I was looking for and easy to use.

29 Nov 2013 Tobias Olesen

Great funktion!

27 Jul 2012 H


20 Jun 2012 Anders Simonsen

Thanks. So I assume you would have preferred something like distFig('Position','Left','Screen','Right');?

20 Jun 2012 Deborah

Nice function. Although I think it doesn't make any sense to accept multiple character input like 'r','l' since only the last input is used by the function.

18 Jun 2012

Removed a misplaced "nargin".

02 Jul 2012

Added the 'Rows' and 'Offset' properties and changed the input mode a more logical way.

03 Jul 2012

Added a few lines to the description.

06 May 2013

A minor update

29 May 2014

The whole function has been updated to support different screen resolutions along with other useful features.

02 Jun 2014

Updated description

19 Aug 2014

Added support for the 2014b (pre)release. Also fixed a minor problem with the 'Units' property of the current axes.

20 Aug 2014

Fixed a minor bug with the new figure handle system of 2014b.

20 Dec 2014

The function has been updated to support the new figure handle system of 2014b and 2015a (Prerelease). Minor bugs have been fixed as well.

Contact us