A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/8614 below:

Plotting of DatetimeIndex directly with matplotlib no longer gives datetime formatted axis (0.15) · Issue #8614 · pandas-dev/pandas · GitHub

From http://stackoverflow.com/questions/26526230/plotting-datetimeindex-on-x-axis-with-matplotlib-creates-wrong-ticks-in-pandas-0

df = pd.DataFrame({'RandomValues': np.random.randint(1, 50, 60)},
                  index=pd.date_range("2012-01-01", periods=60))

Plotting of course works:

In [79]: df.plot()
Out[79]: <matplotlib.axes._subplots.AxesSubplot at 0xf571550>

But plotting with matplotlib's plot functions gives no longer a datetime formatted x-axis, but just ints:

In [80]: plt.plot(df.index, df.RandomValues)
Out[80]: [<matplotlib.lines.Line2D at 0xfb5f748>]

Reason: matplotlibs plot calls np.atleast_1d on the input (https://github.com/matplotlib/matplotlib/blob/v1.4.0/lib/matplotlib/axes/_base.py#L220). Previously this returned an Index, now it returns a array of datetime64 values, which matplotlib can't handle.

Issues:

It seems there was some discussion about this in the Index-no-subclass PR: #7891 (comment) and #7891 (comment) (I commented there about exactly this issue, but I don't know why we didn't look further in it then)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4