简体   繁体   中英

Time Series Plot Seaborn with MultiIndex

I have the following dataset:

                     Count
Submit date   Code
2019-09-01    1      24 
2019-09-01    2      29
2019-09-01    3      11
2019-09-01    4      55 
2019-09-01    5      NaN
2019-09-02    1      9
2019-09-02    2      19
2019-09-02    3      NaN
2019-09-02    4      71 
2019-09-02    5      8 
2019-09-03    1      5 
...

The dataset spans three months and counts the occurrence of five codes per day.

In order to plot the data I have just used the following code:

groupeddataset['Count'].unstack().fillna(0).plot(figsize=(60,20),lw = 3, marker = "o", ms = 3)

I am wondering though, how this can be done using seaborn and a lineplot ?

这是你想要的?

sns.lineplot(x='Submit date', y='Count', style='Code', data=groupeddataset.reset_index())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM