title: Resize axes to fit image
body: <p>How can I resize my axes on a matlab GUI to fit exactly with the size of the image I just resized?</p>
  
  <p>I have this:</p>
  
  <pre><code>I = imread('honolulu.png');
  
  I = imresize(im2double(I), [600, 700]);
  </code></pre>
  
  <p>After that I am drawing a grid on the pictures, but because the axes size is different the grid does not look good. However, if I create a figure and I do it on a figure outside the GUI it looks perfect.
  Full code:</p>
  
  <pre><code>%Load map
  
  I = imread('honolulu.png');
  
  %Resize image to be multiple of 50 in each axis.
  I = imresize(im2double(I), [600, 700]);
  
  %Draw grid of 50x50 pixels.
  I(50:50:end, :, :) = 255;
  I(:, 50:50:end, :) = 255;
  axes(handles.axes1);
  h = handles.axes1;imshow(I);
  
  while (ishandle(h))
      try
          [x, y] = ginput(1);
      catch me
          %break loop in case image is closed.
          break;
      end
  
      %Compute top left coordinate of block clicked.
      x0 = floor((x-1)/50)*50;
      y0 = floor((y-1)/50)*50;
  
      %Set block RGB to random color.
      I(y0+1:y0+50-1, x0+1:x0+50-1, 1) = rand();
      I(y0+1:y0+50-1, x0+1:x0+50-1, 2) = rand();
      I(y0+1:y0+50-1, x0+1:x0+50-1, 3) = rand();
  
      imshow(I);
  end
  % Choose default command line output for city_planning
  handles.output = hObject;
  
  % Update handles structure
  guidata(hObject, handles);
  </code></pre>
  
  <p>How it looks vs how it is supposed to look</p>
  
  <p><a href="https://i.stack.imgur.com/D04Dd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D04Dd.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/D04Dd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tETRE.jpg" alt="enter image description here"></a></p>