title: Adjusting size of plot in Matlab so that graph does not get cut off by edge of plot window
body: <p>I've created a plot in Matlab, but unfortunately the side of the plot is cut off by the plotting window.  Here is the code that I've used to create the plot:</p>
  
  <pre><code>% create a plot with dots and with bold sides
  point = num(:, 1);
  depth = num(:, 2);
  hfig = plot(point, depth, '-s', 'Color', 'k', 'MarkerFaceColor', 'k', 'MarkerEdgeColor', 'k', 'MarkerSize', 10);
  
  % make the outside of the graph bold
  set(gca, 'LineWidth', axis_size);
  set(gca,'FontSize', ticksize, 'FontName', fontname);
  set(gca, 'Position', [0.2 0.2 0.8 0.4])
  xlabel('Point Number')
  ylabel('Depth (cm)')
  </code></pre>
  
  <p>Here is the output:</p>
  
  <p><img src="https://i.stack.imgur.com/cg28i.png" alt="Cutoff image"></p>
  
  <p>Notice how the side of the plot has been cut off.  Alternately, here is a picture showing what I want to achieve:</p>
  
  <p><img src="https://i.stack.imgur.com/yJutt.png" alt="What I want to achieve"></p>
  
  <p>I simply created the plot without the call to <code>set(gca, 'Position', [0.2 0.2 0.8 0.4])</code>, and then resized the plot by resizing the window. </p>
  
  <p>But how do I do this in code? I also want to ensure that I can save out the plot as a PNG file with the same dimensions.  I've been playing around with various combinations of the <code>set()</code> function, and I've been unable to attain what I want to get.</p>