function put_figure_in_corner
% put_figure_in_corner positions a figure according to where other figures are.
%
% Figures 1, 5, 9, etc are put in the top left of the screen; figs 2, 6, 10, etc
% are top right; figs 3, 7, 11, etc are bottom left and figs 4, 8, 12, etc
% are bottom right. This relies on a call to put_figure_in_corner after each
% figure is created.

quadrant = mod((gcf - 1), 4) + 1;
pos = get(gcf, 'Position');
switch quadrant
 case 1
  pos_new = [5 580 pos(3) pos(4)];
 case 2
  pos_new = [575 580 pos(3) pos(4)];
 case 3
  pos_new = [5 130 pos(3) pos(4)];
 case 4
  pos_new = [575 130 pos(3) pos(4)];
end
set(gcf, 'Position', pos_new)
