title: How to position and align a matplotlib figure legend?
body: <p>I have a figure with two subplots as 2 rows and 1 column. I can add a nice looking figure legend with</p>
  
  <pre><code>fig.legend((l1, l2), ['2011', '2012'], loc="lower center", 
             ncol=2, fancybox=True, shadow=True, prop={'size':'small'})
  </code></pre>
  
  <p>However, this legend is positioned at the center of the <strong>figure</strong> and not below the center of the <strong>axes</strong> as I would like to have it. Now, I can obtain my axes coordinates with </p>
  
  <pre><code>axbox = ax[1].get_position()
  </code></pre>
  
  <p>and in theory I should be able to position the legend by specifying the <em>loc</em> keyword with a tuple:</p>
  
  <pre><code>fig.legend(..., loc=(axbox.x0+0.5*axbox.width, axbox.y0-0.08), ...)
  </code></pre>
  
  <p>This works, <strong>except</strong> that the legend is left aligned so that <em>loc</em> specifies the left edge/corner of the legend box and not the center. I searched for keywords such as <em>align</em>, <em>horizontalalignment</em>, etc., but couldn't find any. I also tried to obtain the "legend position", but legend doesn't have a *get_position()* method. I read about *bbox_to_anchor* but cannot make sense of it when applied to a figure legend. This seems to be made for axes legends.</p>
  
  <p>Or: should I use a shifted axes legend instead? But then, why are there figure legends in the first place? And somehow it must be possible to "center align" a figure legend, because <em>loc="lower center"</em> does it too.</p>
  
  <p>Thanks for any help,</p>
  
  <p>Martin</p>