Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rhkarls opened this issue Dec 7, 2012 · 2 comments

Comments

@rhkarls
Copy link

commented Dec 7, 2012

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()]

@changhiskhan

This comment has been minimized.

Copy link
Contributor

commented Dec 7, 2012

pandas plotting machinery tries to match frequencies (and convert to PeriodIndex) if possible and looks like this is a bug caused by using PeriodIndex.asfreq default behavior. We'll put in a fix.
Thanks for the bug report.

@changhiskhan

This comment has been minimized.

Copy link
Contributor

commented Dec 9, 2012

closed via f55dfed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.