Azzera filtri
Azzera filtri

Random ordering of figure numbers

4 visualizzazioni (ultimi 30 giorni)
Christopher Ison
Christopher Ison il 28 Set 2015
Commentato: Jon il 30 Set 2015
When I installed R2015a, figure numbers were then generated in random order. I have a script that produces many graphs at once, then tiles them. I was astonished to find they would no longer display in the order executed. The figure numbers were correct but they did not arrange in numerical order when tiled. This never happened before. Any clues as to what's going on? Could it be the tiling function? I checked get(0, 'Children') and it lists the figures in reverse display order (first is last in the list). FWIW, when the tiling function is not used, figures stack on one another in numerical order.
  3 Commenti
Walter Roberson
Walter Roberson il 28 Set 2015
Are you referring to the tiling feature described over here ?
Mike Garrity
Mike Garrity il 29 Set 2015
This is just a guess, but I suspect that the code you're using to do the tiling is using GCF. If you create a bunch of figures in a row without calling drawnow, then which one becomes GCF is up to the operating system. This was always a bit unpredictable, but with the new multithreaded graphics system which was introduced in R2014b it became rather more unpredictable.
For this sort of thing, it is probably better not to depend on the value of GCF. Instead, use the return value of the figure function. Or, as you've noticed, you can look at the children of the root object. Either of those should be more predictable.
Alternatively, you could try adding some calls to drawnow to your code to try and keep the threads more in synch, but I don't think that would be a very robust solution.
But, as I said, this is just a guess and I may be all wet.

Accedi per commentare.

Risposte (1)

Christopher Ison
Christopher Ison il 29 Set 2015
In response to the request to post the code, here it is. I think we DL'd via The Mathworks long ago. I'm interested to learn how to bring it up to date. I'm surprised this isn't included in MATLAB's core functions.
function tilefigs(tile,border)
% <cpp> tile figure windows usage: tilefigs ([nrows ncols],border_in pixels)
% Restriction: maximum of 100 figure windows
% Without arguments, tilefigs will determine the closest N x N grid
%Charles Plum Nichols Research Corp.
%<cplum@nichols.com> 70 Westview Street
%Tel: (781) 862-9400 Kilnbrook IV
%Fax: (781) 862-9485 Lexington, MA 02173
maxpos = get (0,'screensize'); % determine terminal size in pixels
maxpos(4) = maxpos(4) - 25;
hands = get (0,'Children'); % locate fall open figure handles
hands = sort(hands); % sort figure handles
numfigs = size(hands,1); % number of open figures
maxfigs = 100;
if (numfigs>maxfigs) % figure limit check
disp([' More than ' num2str(maxfigs) ' figures ... get serious pal'])
return
end
if nargin == 0
maxfactor = sqrt(maxfigs); % max number of figures per row or column
sq = [2:maxfactor].^2; % vector of integer squares
sq = sq(find(sq>=numfigs)); % determine square grid size
gridsize = sq(1); % best grid size
nrows = sqrt(gridsize); % figure size screen scale factor
ncols = nrows; % figure size screen scale factor
elseif nargin > 0
nrows = tile(1);
ncols = tile(2);
if numfigs > nrows*ncols
disp ([' requested tile size too small for ' ...
num2str(numfigs) ' open figures '])
return
end
end
if nargin < 2
border = 0;
else
maxpos(3) = maxpos(3) - 2*border;
maxpos(4) = maxpos(4) - 2*border;
end
xlen = fix(maxpos(3)/ncols) - 30+20; % new tiled figure width
ylen = fix(maxpos(4)/nrows) - 45-30; % new tiled figure height
% tile figures by postiion
% Location (1,1) is at bottom left corner
pnum=0;
for iy = 1:nrows
ypos = maxpos(4) - fix((iy)*maxpos(4)/nrows) + border +25; % figure location (row)
for ix = 1:ncols
xpos = fix((ix-1)*maxpos(3)/ncols + 1) + border+7; % figure location (column)
pnum = pnum+1;
if (pnum>numfigs)
break
else
figure(hands(pnum))
set(hands(pnum),'Position',[ xpos ypos xlen ylen ]); % move figure
end
end
end
return
  1 Commento
Jon
Jon il 30 Set 2015
How are you creating the figures? In a loop like this?
for i = 1:N
figure(i) = plot(whatever);
end

Accedi per commentare.

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by