MATLAB Answers

Sonoma Rich
0

Reduce Grey Space around Images in a Figure

Asked by Sonoma Rich
on 26 Apr 2011
Latest activity Commented on by AnnaA
on 2 Sep 2016

I have two images that I want to display side-by-side, but the amount of grey space is large making the images small. How can I reduce the amount of grey space around the images to show more of the images. Below is how I am displaying the images.

subplot(121);
imshow(my_image);
subplot(122);
imshow(my_image2);

  0 Comments

Products

No products are associated with this question.

2 Answers

Answer by Sonoma Rich
on 26 Apr 2011
 Accepted answer

I found this to work better.

     d=0.02; %distance between images
     moon = imread('moon.tif');
     s1=subplot(121);
     imshow(moon);
     s2=subplot(122);
     imshow(moon);
     set(s1,'position',[d 0 0.5-2*d 1])
     set(s2,'position',[0.5+d 0 0.5-2*d 1])

  1 Comment

This is incredible--thank you!


Answer by Paulo Silva
on 26 Apr 2011

   d=0.05; %distance between images
   moon = imread('moon.tif');
   s1=subplot(121);
   imshow(moon);
   s2=subplot(122);
   imshow(moon);
   g1=get(s1,'position');
   set(s1,'position',[0 0 0.5 1])
   g2=get(s2,'position');
   set(s2,'position',[g1(1)+g1(3)+d 0 0.5 1])

  0 Comments


Join the 15-year community celebration.

Play games and win prizes!

Learn more
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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!