python - Plotting time series with seaborn -
i have 2 lists. 1 represents time , looks like
time=[datetime.datetime(2015, 1, 2, 0, 1, 2),datetime.datetime(2015, 1, 2, 0, 5, 2),datetime.datetime(2015, 1, 3, 0, 1, 53),datetime.datetime(2015, 1, 3, 0, 1, 56),datetime.datetime(2015, 1, 5, 0, 1, 2),datetime.datetime(2015, 1, 5, 0, 1, 40),datetime.datetime(2015, 1, 7, 0, 1, 2),datetime.datetime(2015, 1, 7, 0, 1, 30),datetime.datetime(2015, 1, 9, 0, 1, 2),datetime.datetime(2015, 1, 9, 0, 1, 20)]
and other represents corresponding data points:
data=[51.024,3.2179,105.18,31.176,1.1123,1.7861,109.65,0.0,123.890,523.897]
plotting matplotlib easy, rest of statistics done seaborn , keep visuals , use seaborn whole set of results. when use seaborn.tsplot
following error index contains duplicate entries, cannot reshape seaborn
. data list contain duplicates, @ different time points , cannot removed. doing wrong?
edit: if create pandas dataframe, can plot y value using sns.tsplot(y)
, want able use values x-axis, not generated values.
as alternative plotting data seaborn, can use matplotlib
's styles feature same while still plotting within matplotlib
:
from matplotlib import style # seaborn's visual styling inspired ggplot, # style should similar: style.use('ggplot') import matplotlib.pyplot plt import datetime time=[datetime.datetime(2015, 1, 2, 0, 1, 2),datetime.datetime(2015, 1, 2, 0, 5, 2),datetime.datetime(2015, 1, 3, 0, 1, 53),datetime.datetime(2015, 1, 3, 0, 1, 56),datetime.datetime(2015, 1, 5, 0, 1, 2),datetime.datetime(2015, 1, 5, 0, 1, 40),datetime.datetime(2015, 1, 7, 0, 1, 2),datetime.datetime(2015, 1, 7, 0, 1, 30),datetime.datetime(2015, 1, 9, 0, 1, 2),datetime.datetime(2015, 1, 9, 0, 1, 20)] data=[51.024,3.2179,105.18,31.176,1.1123,1.7861,109.65,0.0,123.890,523.897] # replace whatever code using plot # within matplotib, styling should still applied plt.plot(time, data, 'ro') plt.show()
Comments
Post a Comment