我想用matplotlib和seaborn創建一個平滑的折線圖。帶seaborn tsplot的多線圖
這是我的數據幀df
:
hour direction hourly_avg_count
0 1 20
1 1 22
2 1 21
3 1 21
.. ... ...
24 1 15
0 2 24
1 2 28
... ... ...
折線圖應該包含兩行,一個用於direction
等於1,另一個用於direction
等於2的X軸是hour
和Y軸是hourly_avg_count
。
我試過了,但看不到線條。
import pandas as pd
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
plt.figure(figsize=(12,8))
sns.tsplot(df, time='hour', condition='direction', value='hourly_avg_count')
這裏沒有理由使用'tsplot',熊貓繪圖方法就足夠了。 – mwaskom