title: How to add a circle to simple matlab figure?
body: <p>I have a plot of some data (simple 2-d line) and I would like to add circles around some more interesting spots on it. Surprisingly matlab seems to have no simple way to create a physically round circles. I looked on the internet and most answers i found was to either use <code>rectangle('Curvature',[1 1])</code> or <code>pts = linspace(0,2*pi, 100); plot(sin(pts), cos(pts));</code> and <strong>fixing the aspect ration of a plot to 1</strong>. In my case axes have scales that differ by several orders of magnitude so fixing the aspect ration is no option.</p>
  
  <p>I was trying different ways to get the right x/y scale factor but it still seems I'm missing something. My current attempt is:</p>
  
  <pre><code>function hc = circle(x, y, xr)
  
  gca_ylim = get(gca, 'ylim');
  gca_xlim = get(gca, 'xlim');
  gca_pos = get(gca, 'Position');
  gcf_pos = get(gcf, 'Position');
  
  gcf_ar = get(gca, 'DataAspectRatio');
  
  %mod = gca_pos(4)/gca_pos(3) *abs(gca_ylim(2)-gca_ylim(1))/abs(gca_xlim(2)-gca_xlim(1))*gcf_pos(3)/gcf_pos(4);
  mod = gca_pos(4)/gca_pos(3)*gcf_ar(2)/gcf_ar(1)*gcf_pos(3)/gcf_pos(4);
  yr = xr*mod;
  rectangle('Position',[x-xr,y-yr,xr*2,xr*mod*2], 'Curvature',[1,1]);
  end
  </code></pre>
  
  <p>The circles that i got that way are still a bit elongated and I have no idea why. If there is any simple method to get circles in a plot - please share.</p>
  
  <p>PS I know that if I resize plot or add some more stuff to it and change scaling the circles will re-scale with the entire plot. This is not a problem in my case - Figure gets printed out without manual manipulation (no window resizing) and I can add them as the last objects.</p>