Skip to content

TimeSeries shift in plot when plotting different frequencies on same axis #2448

@rhkarls

Description

@rhkarls

using pandas.TimeSeries.plot() causes a shift in the plotted timeseries when plotting two different TimeSeries objects on the same axis. When plotting in subplots or plotting using pylab/matplotlib directly it behaves as expected. Issue remains if objects are DataFrames instead of Series.

Version 0.9.1

Simple code to reproduce:

import pandas as pd
import pylab as pl

ts_ind=pd.date_range('2012-01-01 13:00', '2012-01-02', freq='H')
ts_data=pl.random(12)

hourly timeseries

ts=pd.TimeSeries(ts_data, index=ts_ind)

minute frequency timeseries

ts2=ts.asfreq('T').interpolate()

using TimeSeries.plot()

pl.figure()
ts.plot()
ts2.plot(style='r')

using pylab.plot()

pl.figure()
pl.plot(ts.index, ts.values)
pl.plot(ts2.index, ts2.values, '-r')

using TimeSeries.plot() on different axes

pl.figure()
pl.subplot(211)
ts.plot()
pl.subplot(212)
ts2.plot(style='r')

the two timeseries objects are correct, problem lies with the plotting:

ts.index[ts==ts.max()]
ts2.index[ts2==ts2.max()]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions