我正在尝试从字典中制作堆栈图,其中值是 0 到 1 之间的浮点数列表,列表中值的索引是测量时间 (t1, t2, ...tn)。所有键都具有相同数量的值。例如:
a = {1:[0.3,0.5,0.7], 2:[0.4,0.6,0.8], 5:[0.1,0.15,0.20]}
这样在 t2 时:a[1] = 0.5, a[2] = 0.6, and a[5] = 0.15
,依此类推值列表的其他索引。
我想要一个像这样的堆栈图here http://glowingpython.blogspot.com/2015/04/stacked-area-plots-with-matplotlib.htmlx 轴上的值列表的索引和 y 轴上该索引处的 a[i] 的值,但无法弄清楚如何调整该代码或matplotlib 示例 http://matplotlib.org/examples/pylab_examples/stackplot_demo.html到字典。
Python版本: 3.4
错误(对于我的数据和玩具数据集):
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
建议?