title: Zoom region within a plot in Matlab
body: <p>I'm using Matlab to produce figures, and I'm wondering if there is a way to plot a zoomed region in a figure of the overall data?</p>
  
  <p>I have scatter data plotted over one week, with the x-axis in hours, and I want to zoom into the first 3 hours, and display them within the main figure with the x-axis label of minutes.</p>
  
  <p>The plotting code I have so far is as follows:</p>
  
  <pre><code>allvalsx = marabint(:,2)
  allvalsy = marabint(:,5)
  subvalsx = marabint(1:7,2);
  subvalsy = marabint(1:7,2);
  %% Plots the scatter chart.
  sizemarker = 135
  handle = scatter(allvalsx, allvalsy, sizemarker, '.')
  figure(1)
  axes('Position',[.2 .2 .2 .2])
  handle2 = scatter(subvalsx, subvalsy, '.r')
  title(plotTitle)
  xlabel('Time since treatment (hours)')
  ylabel('Contact angle (deg)')
  
  % Axis scales x1, x2, y1, y2
  axis([0, marabint(length(marabint),2) + 10, 0, 120]);
  
  % This adds a red horizontal line indicating the untreated angle of the
  % sample.
  untreatedLine = line('XData', [0 marabint(length(marabint),2) + 10], 'YData', [untreatedAngle untreatedAngle], 'LineStyle', '-', ...
      'LineWidth', 1, 'Color','r');
  
  % Adding a legend to the graph
  legendInfo = horzcat('Untreated angle of ', untreatedString)
  hleg1 = legend(untreatedLine, legendInfo);
  
  % This encases the plot in a box
      a = gca;
      % set box property to off and remove background color
      set(a,'box','off','color','none')
      % create new, empty axes with box but without ticks
      b = axes('Position',get(a,'Position'),'box','on','xtick',[],'ytick',[]);
      % set original axes as active
      axes(a)
      % link axes in case of zooming
      linkaxes([a b])
  
  set(gcf,'PaperUnits','inches');
  set(gcf,'PaperSize', [8.267 5.25]);
  set(gcf,'PaperPosition',[0 0.2625 8.267 4.75]);
  set(gcf,'PaperPositionMode','Manual');
  set(handle,'Marker','.');
  print(gcf, '-dpdf', '-r150', horzcat('markertest4.pdf'));
  </code></pre>
  
  <p>This produces the following<img src="https://i.stack.imgur.com/XPOUh.png" alt="enter image description here"></p>
  
  <p>Can anyone help me out with this?</p>