如何绘制按不同颜色分组的多个时间序列? [英] How do I plot multiple time series grouped by different colours?

查看:48
本文介绍了如何绘制按不同颜色分组的多个时间序列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用一个图表显示 10 个系列.这些被分成组,例如这个简单的例子:

I am trying to have a single graph displaying a 10 series. These are divided in group such as this simple example :

            Group A | Group B
   time(h)  S1 S2 S3   S4 S5 S6
     0      1  3   1   3  4  5
     24     2  1   3   4  2  1
     48     3  2   2   1  2  2

如何将这 6 个系列添加到一个图表中并按颜色对它们的 A/B 组进行分类?

How can I add these 6 series in a single graph and categorise their group A/B by colour ?

非常感谢!

推荐答案

你可以试试seaborn:

You can try seaborn:

import seaborn as sns

sns.lineplot(data=df.stack(level=[0,1]).reset_index(name='value'),
             x='time', y='value', hue='level_1', style='level_2' 
            )

你会得到:

这篇关于如何绘制按不同颜色分组的多个时间序列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆