我有一个包含三列的数据框。我在两列上做了一组并计算了平均值。我平均后重置索引。现在我想在图上绘图。
我的专栏是
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.3318
X轴上的时间,每种类型的y轴上的值。请帮我。
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
为您完成绘图。