Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Make subplot 2nd image display smaller

Subject: Make subplot 2nd image display smaller

From: Darren LEE

Date: 11 Nov, 2010 02:58:31

Message: 1 of 6

Hi everyone,

I having a problem in subplot display, both my img1 & img2 having
different dimension size. But when using subplot it will display both
img to be the same width. thus my img2 looks too big that having the
same width as img1. How can I keep the original ratio/size Or reduce
img2 dimension?

subplot(1,2,1);
imshow(img1); % Dimension 500 x 500

subplot(1,2,2);
imshow(img2); % Dimension 256 x 256


Thanks in advance.

Subject: Make subplot 2nd image display smaller

From: ImageAnalyst

Date: 11 Nov, 2010 03:13:11

Message: 2 of 6

You can enlarge it manually to override the default size. See this
demo:

clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clearvars; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;

% Read in a standard MATLAB gray scale demo image.
folder = 'C:\Program Files\MATLAB\R2010a\toolbox\images\imdemos';
baseFileName = 'cameraman.tif';
fullFileName = fullfile(folder, baseFileName);
grayImage = imread(fullFileName);

% Display the original gray scale image.
subplot(2, 2, 1); % Upper left
imshow(grayImage, []);
title('Image 1', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')

baseFileName = 'cell.tif';
fullFileName = fullfile(folder, baseFileName);
grayImage2 = imread(fullFileName);

% Display the original gray scale image.
subplot(2, 2, 2); % Upper right
imshow(grayImage2, []);
title('Image 2', 'FontSize', fontSize);

% Display the original gray scale image.
h3=subplot(2, 2, 3); % Upper right
imshow(grayImage2, []);
title('Image 3', 'FontSize', fontSize);
% Get existing default image size.
size2 = get(h3, 'position')
% Enlarge the image.
size3 = size2;
size3(3) = 1.8 * size2(3);
size3(4) = 1.8 * size2(4);
set(h3, 'Position', size3);

Subject: Make subplot 2nd image display smaller

From: Berhanu

Date: 18 Feb, 2011 12:47:08

Message: 3 of 6

if you don't know it, you better keep silent. than stating unnecessary things.

Subject: Make subplot 2nd image display smaller

From: ImageAnalyst

Date: 18 Feb, 2011 12:52:56

Message: 4 of 6

On Feb 18, 7:47 am, Berhanu <u...@compgroups.net/> wrote:
> if you don't know it, you better keep silent. than stating unnecessary things.
----------------------------------------------------------------------------------
Then why didn't you follow your own advice?

Subject: Make subplot 2nd image display smaller

From: Think blue, count two.

Date: 21 Feb, 2011 00:07:09

Message: 5 of 6

On 18/02/11 6:47 AM, Berhanu wrote:
> if you don't know it, you better keep silent. than stating unnecessary things.

That's not very nice to say to someone who attempted to assist you
according to his understanding of what you were asking.

To answer your question:

ah1 = subplot(1,2,1);
image(ah1, Image1);
axis(ah1, 'image');
xsize = get(ah1, 'XLim');
ysize = get(ah1, 'YLim');

ah2 = subplot(1,2,2);
image(ah2, Image2);
axis(ah1, 'image');
set(ah2, 'XLim', xsize, 'YLim', ysize);

Subject: Make subplot 2nd image display smaller

From: ImageAnalyst

Date: 21 Feb, 2011 00:14:49

Message: 6 of 6

I thought Behanu was a different person - some troll - than Darren
Lee. No one attempted to assist Berhanu, and most likely never will.
Although Darren never got back to us, I'd probably still respond to
one of his questions. But Berhanu's on my blacklist.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us