You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From stackoverflow, a question from more than a month ago, but still an issue I think (tested with master).
Basicly, when using ax.invert_xaxis() with datetime x-values, the following exception is raised:
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)
At first it may not seem an error from pandas, as you can trigger it by using pure matplotlib code, but the error comes from pandas\tseries\converter.py. And more, it is by importing pandas that causes working matplotlib code to work no longer:
importnumpyasnpimportmatplotlib.pyplotaspltimportdatetimex=np.array([datetime.datetime(2012, 8, 1, 0, 0),
datetime.datetime(2012, 9, 1, 0, 0),
datetime.datetime(2012, 10, 1, 0, 0)], dtype=object)
y=np.array([-1,0,1])
## Working matplotlib!fig, ax=plt.subplots()
ax.plot(x,y)
ax.invert_xaxis()
plt.show()
importpandasaspd## Same matplotlib not working anymore after importing pandasfig, ax=plt.subplots()
ax.plot(x,y)
ax.invert_xaxis()
plt.show()
CAUSE of the bug:
When using ax.invert_xaxis() the left and right xlim are interchanged. Because of this the delta in PandasAutoDateLocator will be negative (https://github.com/pydata/pandas/blob/master/pandas/tseries/converter.py#L241).
This in turn triggers MilliSecondLocator instead of the normal AutoDateLocator, and causes the error as the datetime range is too big for MilliSecondLocator.
What I don't understand is why this is not happening when using pandas plot to create the axes object (the workaround I gave at stackoverflow):
df=pd.DataFrame(y, index=x, columns=['test'])
## This works as expected!fig, ax=plt.subplots()
df.plot(ax=ax)
ax.invert_xaxis()
plt.show()
The text was updated successfully, but these errors were encountered:
* commit 'v0.12.0rc1-43-g7b2eaa4': (571 commits)
PERF: add ix scalar get benchmark
DOC: more prominent HDFStore store docs about storer/table formats
BUG: invert_xaxis (negative tot_sec) triggers MilliSecondLocator (pandas-dev#3990)
BUG: (GH4192) fixed broken unit test
BUG: (GH4192) Fixed buglet in the broadcasting logic in Series.where
CLN: Ignore warnings generated by 'DROP TABLE IF EXISTS' when table does not exist.
DOC: more cookbook recipies
DOC: update ipython_directive with changes from ipython to restart prompt number at 1 each page
DOC: increased width of text area
TST: fix ujson tests failures on 32-bit
TST: raise when no data are found when trying to dld multiple symbols
TST: Create a MySQL database and run MySQL tests on Travis.
CLN: write the attributes in a HDFStore as strings
TST: remove double call to yahoo finance
DOC to_datetime warning about dayfirst strictness
TST: to_datetime format fixes
DOC: minor io/whatsnew doc edits
BUG/TST: wrong parsing of microseconds with format arg (pandas-dev#4152)
RLS: first release candidate for v0.12.0
BLD: use the wheel url for scikits timeseries
...
From stackoverflow, a question from more than a month ago, but still an issue I think (tested with master).
Basicly, when using
ax.invert_xaxis()
with datetime x-values, the following exception is raised:At first it may not seem an error from pandas, as you can trigger it by using pure matplotlib code, but the error comes from pandas\tseries\converter.py. And more, it is by importing pandas that causes working matplotlib code to work no longer:
CAUSE of the bug:
When using
ax.invert_xaxis()
the left and right xlim are interchanged. Because of this thedelta
in PandasAutoDateLocator will be negative (https://github.com/pydata/pandas/blob/master/pandas/tseries/converter.py#L241).This in turn triggers MilliSecondLocator instead of the normal AutoDateLocator, and causes the error as the datetime range is too big for MilliSecondLocator.
What I don't understand is why this is not happening when using pandas
plot
to create the axes object (the workaround I gave at stackoverflow):The text was updated successfully, but these errors were encountered: