栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

具有seaborn tsplot的多线图

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

具有seaborn tsplot的多线图

这个

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。因此,可能仍然值得使用其他方式来绘制数据。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/640530.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号