title: How to add legend below subplots in matplotlib?
body: <p>I am trying to add a legend below a 3-column subplot figure.</p>
  
  <p>I have tried the following:</p>
  
  <pre><code>fig, ax = plt.subplots(ncols=3)
  ax[0].plot(data1)
  ax[1].plot(data2)
  ax[2].plot(data3)
  
  ax_sub = plt.subplot(111)
  box = ax_sub.get_position()
  ax_sub.set_position([box.x0, box.y0 + box.height * 0.1,box.width, box.height * 0.9])
  ax_sub.legend(['A', 'B', 'C'],loc='upper center', bbox_to_anchor=(0.5, -0.3),fancybox=False, shadow=False, ncol=3)
  plt.show()
  </code></pre>
  
  <p>However, this creates just one empty frame. When I comment out the ax_sub part, my subplots show up nice (but without a legend...)...</p>
  
  <p>Many thanks!</p>
  
  <p>This is closely related to <a href="https://stackoverflow.com/questions/4700614/how-to-put-the-legend-out-of-the-plot">How to put the legend out of the plot</a></p>