If I run the following code:
import pandas as pd
from datetime import datetime
import numpy as np
import matplotlib.pyplot as plt
#df = pd.DataFrame(np.random.randn(3,1), index=[8,9,10], columns=['test'])
df = pd.DataFrame(np.random.randn(3,1), index=[datetime(2012,8,1),datetime(2012,9,1),datetime(2012,10,1)], columns=['test'])
fig = plt.figure()
ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8])
ax1.invert_xaxis()
ax1.plot(df.index, df['test'])
fig.show()
I get an exception:
RuntimeError: MillisecondLocator estimated to generate 5270400 ticks from 2012-08-01 00:00:00+00:00 to 2012-10-01 00:00:00+00:00: exceeds Locator.MAXTICKS* 2 (2000)
It works fine if I disable the "invert_xaxis" command, and also if the index uses non-Datetime values.
I've seen some similar bugs reported (eg here and here) when plotting a dataframe with out-of-order date index but this was fixed in an earlier version of pandas.
Any suggestions on a workaround ? I'm using matplotlib 1.2.1 and pandas 0.11.0