title: Boxplot placed on time axis
body: <p>I want to place a series of (matplotlib) boxplots in a time axis. They are series of measurements taken on different days along a year. The dates are not evenly distributed and I am interested on the variation along time.</p>
  <hr />
  <h2>Easy version</h2>
  <p>I have a pandas DataFrame with indexes and series of numbers, more or less like this: (notice the indexes):</p>
  <pre><code>np.random.seed(12345)
  data = np.array( [ np.random.normal( i, 1, 10 ) for i in range(3) ] )
  ii = np.array([ 3, 5, 8 ] )
  df = pd.DataFrame( data=data, index=ii )
  </code></pre>
  <p>For each index, I need to make a boxplot, which is no problem:</p>
  <pre><code>plt.boxplot( [ df.loc[i] for i in df.index ], vert=True, positions=ii )
  </code></pre>
  <p><a href="https://i.stack.imgur.com/8e6Px.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8e6Px.png" alt="enter image description here" /></a></p>
  <h2>Time version</h2>
  <p>The problem is, I need to place the boxes in a time axis, i.e. place the boxes on a concrete date</p>
  <pre><code>np.random.seed(12345)
  data = np.array( [ np.random.normal( i, 1, 10 ) for i in range(3) ] )
  dates = pd.to_datetime( [ '2015-06-01', '2015-06-15', '2015-08-30' ] )
  df = pd.DataFrame( data=data, index=dates )
  plt.boxplot( [ df.loc[i] for i in df.index ], vert=True )
  </code></pre>
  <p><a href="https://i.stack.imgur.com/XSZBR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XSZBR.png" alt="enter image description here" /></a></p>
  <p>However, if I incorporate the positions:</p>
  <p><code>ax.boxplot( [ df.loc[i] for i in df.index ], vert=True, positions=dates )</code></p>
  <p>I get an error:</p>
  <blockquote>
  <p>TypeError: Cannot compare type 'Timedelta' with type 'float'</p>
  </blockquote>
  <p>A look up on the docs shows:</p>
  <p><code>plt.boxplot?</code></p>
  <blockquote>
  <p>positions : array-like, default = [1, 2, ..., n]</p>
  <p>Sets the positions of the boxes. The ticks and limits are automatically set to match the positions.</p>
  </blockquote>
  <hr />
  <h2>Wished time version</h2>
  <p>This code is intended to clarify, narrow down the problem. The boxes should apppear there, where the blue points are placed in the next figure.</p>
  <pre><code>np.random.seed(12345)
  data = np.array( [ np.random.normal( i, 1, 10 ) for i in range(3) ] )
  dates = pd.to_datetime( [ '2015-06-01', '2015-06-15', '2015-08-30' ] )
  df = pd.DataFrame( data=data, index=dates )
  
  fig, ax = plt.subplots( figsize=(10,5) )
  x1 = pd.to_datetime( '2015-05-01' )
  x2 = pd.to_datetime( '2015-09-30' )
  ax.set_xlim( [ x1, x2 ] )
  
  # ax.boxplot( [ df.loc[i] for i in df.index ], vert=True ) # Does not throw error, but plots nothing (out of range)
  # ax.boxplot( [ df.loc[i] for i in df.index ], vert=True, positions=dates ) # This is what I'd like (throws TypeError)
  
  ax.plot( dates, [ df.loc[i].mean() for i in df.index ], 'o' )  # Added to clarify the positions I aim for
  </code></pre>
  <p><a href="https://i.stack.imgur.com/NdpYs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NdpYs.png" alt="enter image description here" /></a></p>
  <hr />
  <p><strong>Is there a method to place boxplots in a time axis?</strong></p>
  <hr />
  <p>I am using:</p>
  <p>python: 3.4.3 + numpy: 1.11.0 + pandas: 0.18.0 + matplotlib: 1.5.1</p>