|
From: Benjamin R. <ben...@ou...> - 2014-12-02 19:08:15
|
Ok, then this looks like a legitimate bug in span_where(). It probably isn't applying units, somehow. This isn't really a problem with pandas, it is an issue where we aren't being consistent in applying units for all plotting functions. Could you file a bug report, please? Cheers! Ben Root On Tue, Dec 2, 2014 at 11:15 AM, Fabien <fab...@gm...> wrote: > 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() > #------------------------------------------- > > > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > > http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |