Join GitHub today
Can't pickle plots from dataframes with date indexes #18439
Already report this at matplotlib/matplotlib#9828, but it appears that that issue is caused by pandas using a lambda in the format_dateaxis function. I don't know if there is a way around this, but it prevents pandas-produced matplotlib figures from being pickled.
MPL Bug report
Trying to pickle a figure that was produced using pandas.plot(), which includes a datetime index. Not sure if this is a pandas bug, or MPL.
Here's an example:
I've tried this with a manually constructed DF, and it worked, so I'm not sure why this is happening. I'm including a pickle of the above sample DF for investigation. It is originally a slice from an xarray, from a netcdf dataset.
Using Conda on linux (kubuntu 17.10):
Got it. Simple repro. code. The index which length
import pandas as pd from matplotlib import pyplot as plt import numpy import pickle %matplotlib inline idx = pd.DatetimeIndex(['2002-07-28 08:00:00', '2002-07-28 08:30:00', '2002-07-28 09:00:00']) s = pd.Series([1, 2, 3], index=idx) s.plot() fig = plt.gcf() pickle.dump(fig, open('test.pkl', 'wb'))