|
From: Fabien <fab...@gm...> - 2014-12-02 16:15:51
|
On 02.12.2014 16:59, Benjamin Root wrote: > Does the workaround posted here fix things for you? > https://github.com/matplotlib/matplotlib/issues/3727#issuecomment-60899590 sorry it doesn't. I updated the test case below (including the workaround, I hope I got it right). The strange thing is that fill_between() works fine, but pan_where() is the problem. Thanks! #------------------------------------------- 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 import matplotlib.units as units units.registry[np.datetime64] = pd.tseries.converter.DatetimeConverter() # init the dataframe 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 # This is working (but its not what I want) x = np.arange(5) fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #This is not x = df.index.values fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #This is producing an error x = df.index fig = plt.figure() ax = fig.add_subplot(111) plt.plot(x, df['data'], 'k') c = span_where(x, ymin=0, ymax=4, where=df['cond'], color='green') ax.add_collection(c) plt.show() #------------------------------------------- |