Code covered by the BSD License  

Highlights from
Precise Figure Placing

image thumbnail
from Precise Figure Placing by Markus Buehren
This contribution provides functions for precisely placing a figure to a given screen location.

placefiguredemo
function placefiguredemo
%PLACEFIGUREDEMO  Demonstration of placefigure functionality.
%
%		Markus Buehren
%		Last modified: 20.04.2008
%
%		See also PLACEFIGURE.

tag = 'placefiguredemo';

% set all existing figures to invisible
ch = get(0, 'Children');
for k =1:length(ch)
	if strcmp(get(ch(k), 'Type'), 'figure')
		set(ch(k), 'Visible', 'off');
	end
end

% let a small figure rotate, change tool bar and menu bar
if 0
	removealldemofigures__(tag);
	fh = figure('Tag', tag, 'NumberTitle', 'off', 'Name', 'Rotating figure');
	drawnow;
	row = [1 1 1 2 3 3 3 2];
	col = [1 2 3 3 3 2 1 1];
	for n=1:3
		for k=1:length(row)
			placefigure(fh, [3, 3, row(k), col(k)]);
			pause(0.4);
		end
		if n==1
			set(fh, 'ToolBar', 'none');
		end
		if n==2
			set(fh, 'MenuBar', 'none');
		end
	end
end

% generate several figures in different alignments
nOfRowsVec = [1 1 2 2 2 3 3 4];
nOfColsVec = [1 2 1 2 3 2 3 4];
for k = 1:length(nOfRowsVec)
	removealldemofigures__(tag)
	for row = 1:nOfRowsVec(k)
		for col = 1:nOfColsVec(k)
			fh = figure('Tag', tag, 'NumberTitle', 'off', ...
				'Name', sprintf('Figure (%d,%d)', row, col));
			drawnow;
			if nOfRowsVec(k) * nOfColsVec(k) > 4
				set(fh, 'ToolBar', 'none');
			end
			if nOfRowsVec(k) * nOfColsVec(k) > 8
				set(fh, 'MenuBar', 'none');
			end			
			placefigure(fh, [nOfRowsVec(k) nOfColsVec(k) row col]);
		end
	end
	pause(2);
end

% remove all figures generated by this demo
disp('Deleting all generated figures in five seconds.');
pause(5);
removealldemofigures__(tag)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function removealldemofigures__(tag)
ch = get(0, 'Children');
for k =1:length(ch)
	if strcmp(get(ch(k), 'Type'), 'figure') && strcmp(get(ch(k), 'Tag'), tag)
		delete(ch(k));
	end
end

Contact us at files@mathworks.com