Skip to content

Timestamp when plotting hourly time series with base != 0 #2571

Closed
@bmu

Description

@bmu

If I plot an hourly time series with a different base (don't know if this is correct englisch I mean if it is not 12:00, 13:00, ... but something like 12:30, 13:30, ...) the values are plotted as full hours at the xaxis. If I convert to a resolution of '60min' it works.

In [250]: idx = pd.date_range('2012-12-20', periods=24, freq='H') + datetime.timedelta(minutes=30)

In [251]: idx
Out[251]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-12-20 00:30:00, ..., 2012-12-20 23:30:00]
Length: 24, Freq: H, Timezone: None

In [252]: df = pd.DataFrame(np.arange(24), index=idx)

In [253]: df.plot(style='r.')
Out[253]: <matplotlib.axes.AxesSubplot at 0xd34920d0>

In [254]: df2 = df.resample('60min', base=30, closed='right')

In [255]: df2.index
Out[255]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-12-20 00:30:00, ..., 2012-12-20 23:30:00]
Length: 24, Freq: 60T, Timezone: None

In [256]: df2.plot(style='r.')
Out[256]: <matplotlib.axes.AxesSubplot at 0xd43fde90>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions