pdvega icon indicating copy to clipboard operation
pdvega copied to clipboard

Plotting data with datetimes

Open StephanieWillis opened this issue 7 years ago • 1 comments
trafficstars

The plotting library doesn't seem to work when I try and plot a datetime object. It can handle just dates but when there is an associated time the plot builds without error but no line is plotted.

Code here that doesn't work:

import pandas as pd import matplotlib.pyplot as plt import pdvega

rng = pd.date_range('1/1/2011', periods=72, freq='H') rng = [pd.Timestamp(r) for r in rng] ts = pd.Series(np.random.randn(len(rng)), index=rng)

ts.vgplot.line() #this doesn't throw any errors but no data is shown

ts.plot() #this works on the other hand plt.show()

StephanieWillis avatar Jun 06 '18 22:06 StephanieWillis

Thanks – I think this has to do with the way temporal data is serialized to JSON.

jakevdp avatar Jun 06 '18 22:06 jakevdp