这个
tsplot有点奇怪,或者至少被扼杀了。如果提供了一个数据框,则假定必须存在一个
unit和一个
time列,因为它在内部围绕这两个旋转。因此,要
tsplot绘制多个时间序列,您还需要提供一个参数
unit。这可以与相同
condition。
sns.tsplot(df, time='hour', unit = "direction", condition='direction', value='hourly_avg_count')
完整的例子:
import numpy as npimport pandas as pdimport seaborn as snsimport matplotlib.pyplot as plthour, direction = np.meshgrid(np.arange(24), np.arange(1,3))df = pd.Dataframe({"hour": hour.flatten(), "direction": direction.flatten()})df["hourly_avg_count"] = np.random.randint(14,30, size=len(df))plt.figure(figsize=(12,8))sns.tsplot(df, time='hour', unit = "direction", condition='direction', value='hourly_avg_count')plt.show()还值得注意的是,从seaborn版本0.8开始不推荐使用tsplot。因此,可能仍然值得使用其他方式来绘制数据。



