title: Matplotlib: how to show legend elements horizontally?
body: <p>I'd like to set the legend to be displayed horizontally. I do not mean the <em>text</em> of the legend  like described in the post <a href="https://stackoverflow.com/questions/32012120/matplotlib-legend-vertical-rotation">Matplotlib legend vertical rotation</a>. My <em>actual</em> case includes an arbitrary number of series specified with a widget. But the following example represents the gist of the challenge:</p>
  <p><strong>Snippet:</strong></p>
  <pre><code># Imports
  import pandas as pd
  import matplotlib.pyplot as plt
  import numpy as np
  
  # data
  np.random.seed(123)
  x = pd.Series(np.random.randn(100),index=pd.date_range('1/1/2000', periods=100)).cumsum()
  y = pd.Series(np.random.randn(100),index=pd.date_range('1/1/2000', periods=100)).cumsum()
  z = pd.Series(np.random.randn(100),index=pd.date_range('1/1/2000', periods=100)).cumsum()
  df = pd.concat([x,y,z], axis = 1)
  
  # plot 
  ax = plt.subplot()
  for col in (df.columns):
      plt.plot(df[col])
  plt.legend(loc=&quot;lower left&quot;)
  plt.xticks(rotation=90)
  plt.show()
  </code></pre>
  <p><strong>Plot:</strong></p>
  <p><a href="https://i.stack.imgur.com/9HgTq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9HgTq.png" alt="enter image description here" /></a></p>
  <p>The default layout seems to be vertical.
  Looking at the details of <code>help(ax.legend)</code> and the <a href="https://matplotlib.org/2.0.0/api/_as_gen/matplotlib.axes.Axes.legend.html" rel="noreferrer">docs</a> , there does not seem to be a straight forward way to change this to horizontal. Or is there?</p>
  <hr />
  <p><strong>Edit - Desired Legend:</strong> (using MS Paint)</p>
  <p><a href="https://i.stack.imgur.com/IaDEC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IaDEC.png" alt="enter image description here" /></a></p>