Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: different size subwindows?
Date: Mon, 6 Oct 2008 10:00:36 -0400
Organization: The MathWorks, Inc.
Lines: 44
Message-ID: <gcd5m5$ehs$1@fred.mathworks.com>
References: <gcbeeq$g75$1@fred.mathworks.com> <gccnmq$fdu$1@fred.mathworks.com> <gcctti$58$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1223301637 14908 144.212.105.187 (6 Oct 2008 14:00:37 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 6 Oct 2008 14:00:37 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:493819



"David Doria" <daviddoria@gmail.com> wrote in message 
news:gcctti$58$1@fred.mathworks.com...
> sure sure, 4x as many pixels, i mean twice as many per dimension.
>
> So I've done something like this:
>
> spax1 = subplot(1,2,1); imshow(Original)
> spax2 = subplot(1,2,2);
> set(gca, 'position',[.1  .1  .8  .6]);
> imshow(nearest)
>
> Is there not a more automatic way to do this, where it sizes them based on 
> their size, perhaps(haha)?

Set the Units property of spax1 and spax2 to pixels, then get their Position 
properties and update the last two components of the Position based on the 
sizes of the images.


Original = imread('eight.tif');
nearest = imresize(Original, 2, 'nearest');
figure
spax1 = subplot(1,2,1); imshow(Original)
spax2 = subplot(1,2,2); imshow(nearest)
set([spax1, spax2], 'Units', 'pixels')
P1 = get(spax1, 'Position');
P2 = get(spax2, 'Position');
% Assuming Original is a 2-D matrix, not a 3-D array
set(spax1, 'Position', [P1(1:2) size(Original)./2]);
set(spax2, 'Position', [P2(1:2) size(nearest)./2]);


You may also want to adjust the first two components, to "recenter" the axes 
in their subplot area.  Note, however, that this won't update the size of 
the axes if you resize the figure.  You might want to reset the Units 
property to 'normalized' after the code above if that's necessary or useful 
for your application.

-- 
Steve Lord
slord@mathworks.com