title: How to enforce both xlim and ylim while using ax.axis('equal')?
body: <p>I want to use <code>ax.axis('equal')</code> to force even spacing on X &amp; Y, but I also want to prescribe specific ranges for the X and Y axes. If the margins are also fixed, the problem is over constrained and the result is shown on the left side of the Figure <a href="https://i.stack.imgur.com/Lv0mX.png" rel="nofollow noreferrer">1</a>. If instead, the margins were allowed to automatically increase themselves to take up the slack, then <code>xlim</code> and <code>ylim</code> could stay as I set them while still satisfying <code>axis('equal')</code>. An example of what I'm after is shown on the right side of Figure <a href="https://i.stack.imgur.com/Lv0mX.png" rel="nofollow noreferrer">1</a>. <strong>How can I allow the plot margins to "float"?</strong></p>
  
  <pre><code>f,ax=plt.subplots(1) #open a figure
  ax.axis('equal') #make the axes have equal spacing
  ax.plot([0,20],[0,20]) #test data set
  
  #change the plot axis limits
  ax.set_xlim([2,18]) 
  ax.set_ylim([5,15])
  
  #read the plot axis limits
  xlim2=array(ax.get_xlim())
  ylim2=array(ax.get_ylim())
  
  #define indices for drawing a rectangle with xlim2, ylim2
  sqx=array([0,1,1,0,0])
  sqy=array([0,0,1,1,0])
  
  #plot a thick rectangle marking the xlim2, ylim2
  ax.plot(xlim2[sqx],ylim2[sqy],lw=3) #this does not go all the way around the edge
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Lv0mX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lv0mX.png" alt="actual and desired output"></a>
  Figure 1: output from the above code snippet.</p>