Skip to content

BUG: plotting daily data with two-day gaps #1668

@lesteve

Description

@lesteve

Hi,

you should be able to copy and paste this in a ipython --pylab session:

import pandas
index = pandas.date_range(start='2001-1-1', end='2001-1-10', freq='D')
data = index.day
ts = pandas.TimeSeries(index=index, data=data)
tsWithGaps = ts[:3].append(ts[5:])
figure()
tsWithGaps.plot(style='o')
figure()
tsWithGaps.asfreq('D').plot(style='o')

I tried this snippet with 0.8.2.dev-7c54141 (i.e. latest git version as I write). The two plots below come from an improved version of the snippet which prints the timeseries on the plot.

The first plot I get looks weird (wrong label for January 5th + double data point on the 8th)
http://imgur.com/LFJup,aYLYJ#0
The timeseries is printed on the plot and looks perfectly fine.

The second plot with the explicitly resampled ts is fine:
http://imgur.com/LFJup,aYLYJ#1

Trying to tweak the parameters a 3-day gap looks fine and you get x axis labelling like plt.plot_date. She 2-day gaps seems always broken, although in a more subtle way than the plot above (generally the label before the gap is wrong but I don't get double data points). It looks like a timeseries with 2-day gaps is close enough to a regular index timeseries (maybe because of week-ends) and the index labelling goes wrong somewhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions