0

I have 2 lists. One represents time and 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 the 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 this with matplotlib is easy, but the rest of the statistics is done with seaborn and I would like to keep the visuals and use seaborn for the whole set of results. When I use seaborn.tsplot I get the following error index contains duplicate entries, cannot reshape seaborn. The data list does contain duplicates, but they are at different time points and cannot be removed. What am I doing wrong?

Edit: if I create pandas dataframe, I can plot the y value using sns.tsplot(y), but I want to be able to use my values for x-axis, not the generated values.

cphlewis
  • 15,759
  • 4
  • 46
  • 55
user20150316
  • 101
  • 2
  • 8
  • You might want to see my comment [here](http://stackoverflow.com/questions/28914502/getting-word-recommendations-based-on-a-given-word-from-a-list-of-words#comment46087200_28914502) on providing sample data – YXD Mar 16 '15 at 23:26
  • 1
    I added one part of actual data. time is already sorted. – user20150316 Mar 16 '15 at 23:42
  • 2
    You're more likely to get help if you provide a small, complete example of the problem -- data and the failing line of code that we can cut-and-paste in one action into our environments to work with. – cphlewis Mar 17 '15 at 04:35

1 Answers1

1

As an alternative to plotting your data with seaborn, you can use matplotlib's styles feature to get the same look while still plotting within matplotlib:

from matplotlib import style
# Seaborn's visual styling was inspired by ggplot,
#   so this style should be very similar:
style.use('ggplot')

import matplotlib.pyplot as 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 this with whatever code you were using to plot
#   within matplotib, the styling should still be applied
plt.plot(time, data, 'ro')
plt.show()
Marius
  • 58,213
  • 16
  • 107
  • 105
  • You can also just plot with matplotlib functions when seaborn is imported and it will pick up the seaborn style. – mwaskom Mar 17 '15 at 17:04