Closed
Description
System:
python 3.3 on linux mint
pandas 0.15.1
matplotlib 1.4.2
Description of the problem:
Trying to use collections.BrokenBarHCollection.span_where() with pandas timeseries as x values throws an error: TypeError: float() argument must be a string or a number.
see: http://matplotlib.1069221.n5.nabble.com/BrokenBarHCollection-with-pandas-timeseries-td44534.html
Minimal example reproducing the error:
import pandas as pd
import numpy as np
from datetime import datetime as dt
import matplotlib.pyplot as plt
import matplotlib.collections as collections
span_where = collections.BrokenBarHCollection.span_where
time = pd.date_range(pd.datetime(1950,1,1), periods=5, freq='MS')
df = pd.DataFrame(np.arange(5), index=time, columns=['data'])
df['cond'] = df['data'] >= 3
fig = plt.figure()
plt.plot(df.index, df['data'], 'k')
c = span_where(df.index, ymin=0, ymax=4, where=df['cond'], color='green')