我想用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