我有一个有三列的数据帧。我在两列上做了一个group by,并计算了平均值。我在mean之后重置了索引。现在我想在图表上作图。
我的专栏是
Type Time Value
A 0:15:00 5.3718
0:30:00 3.4776
0:45:00 5.6616
1:00:00 0.1638
1:15:00 5.2206
1:30:00 2.6544
1:45:00 0.2982
2:00:00 0.1638
B 0:15:00 6.8376
0:30:00 0.3402
0:45:00 0.3276
1:00:00 0.168
1:15:00 0.252
1:30:00 6.0858
1:45:00 0.336
2:00:00 0.2394
C 0:15:00 0.1638
0:30:00 0.3276
0:45:00 0.336
1:00:00 0.336
1:15:00 0.168
1:30:00 0.2394
1:45:00 0.3402
2:00:00 0.3318X轴上的时间,每种类型的y轴上的值。请帮帮我。
发布于 2019-03-28 06:57:59
import matplotlib.pyplot as plot
timestamp_list = ['0:15:00','0:30:00','0:45:00','1:00:00','1:15:00','1:30:00','1:45:00','2:00:00']
a_list = [5.3718, 3.4776, 5.6616, 0.1638, 5.2206, 2.6544, 0.2982, 0.1638]
b_list = [6.8376, .03402, 0.3276, 0.168, 0.252, 6.0858, 0.336, 0.2394]
c_list = [0.1638, 0.3276, 0.336, 0.336, 0.168, 0.2394, 0.3402, 0.3318]
plot.plot(timestamp_list, a_list)
plot.plot(timestamp_list, b_list)
plot.plot(timestamp_list, c_list)
plot.xlabel('Time')
plot.show()基本上,我使用matplotlib作为绘图模块,如果您还没有安装,可以使用pip安装它。
因为您所有的三种类型都共享相同的时间戳,所以我们需要做的就是将a、b、c类型的值放入它们自己的列表中,并调用pyplot为您绘制曲线。
https://stackoverflow.com/questions/55387424
复制相似问题