我试图绘制一组按时间排序的值的序列,其中每个值用不同的颜色表示。例如,如果我的价值观是
state_seq = [2, 2, 2, 2, 0, 0, 0, 1, 3, 6, 3, 3, 3, 0, 0]
time_seq = ['2013-05-29 09:31:00', '2013-05-29 09:46:00', '2013-07-23 12:28:00', '2013-07-23 01:53:00', '2013-08-05 02:02:00', '2013-08-05 02:08:00', '2013-08-05 04:28:00', '2013-08-06 10:20:00', '2013-08-06 03:03:00', '2013-08-06 04:13:00', '2013-08-06 04:17:00', '2013-08-06 04:36:00', '2013-08-07 11:07:00', '2013-08-07 12:28:00', '2013-08-07 12:31:00']
我想用一种颜色来表示state-seq的每一个独特元素,并绘制序列图。到目前为止,我用seaborn palplot以一种微不足道的方式来完成这件事
^{pr2}$这给了我一些类似的东西(这个输出可能与代码片段不完全匹配-为了更好地清晰起见,我编辑了代码)
这种方法有一个缺陷,我不能用x轴表示我的时间标签。有没有更好的python替代方案可能类似于这里解释的R-package TraMineR Is it possible to make a graph with pattern fills using TraMineR and R base graphs?
我假设您希望每个值都是方形框,而不考虑每个值之间的时间间隔。要有一个表示时间间隔的宽度,可以convert ^{} to datetime objects ,然后直接用matplotlib绘制日期。在
产生:
相关问题 更多 >
编程相关推荐