Thread Subject: different size subwindows?

Subject: different size subwindows?

From: David Doria

Date: 5 Oct, 2008 22:18:02

Message: 1 of 4

Original = imread('../lena.bmp');
nearest = imresize(Original, 2, 'nearest');
figure
spax1 = subplot(1,2,1); imshow(Original)
spax2 = subplot(1,2,2); imshow(nearest)

I would expect the image on the right to be twice as large as the image on the left, but they are displayed the same size. The variables contain twice as many pixels, so why isn't this reflected in the display?

Thanks,
Dave

Subject: different size subwindows?

From: Jan Simon

Date: 6 Oct, 2008 10:02:02

Message: 2 of 4

Dear David Doria!

> Original = imread('../lena.bmp');
> nearest = imresize(Original, 2, 'nearest');
> figure
> spax1 = subplot(1,2,1); imshow(Original)
> spax2 = subplot(1,2,2); imshow(nearest)
>
> The variables contain twice as many pixels, so why isn't this reflected in the display?

The sizes of the created axes objects are determined by the SUBPLOT command. In consequence, the 2nd plot contains 4 times (not twice) more data points (not pixels) as the 1st one. Try it with a 1x1 picture!

To create larger pictures, you can adjust the POSITION property of the spax1/2 objects.

Jan

Subject: different size subwindows?

From: David Doria

Date: 6 Oct, 2008 11:48:02

Message: 3 of 4

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)?

Thanks,
Dave

Subject: different size subwindows?

From: Steven Lord

Date: 6 Oct, 2008 14:00:36

Message: 4 of 4


"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

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com