我正在努力通过pylab模块绘制一个包含两个列表的柱状图(我需要使用它)
第一个列表,totalTime,由程序内计算的7个浮点值填充。在
第二个列表,raceTrack,由7个字符串值填充,这些值表示比赛跑道的名称。在
totalTime[0]是在赛道[0]上花费的时间,totalTime[3]是在赛道[3]上花费的时间,等等。。。在
我整理了数组并将值四舍五入到小数点后2位
totalTimes.sort()
myFormattedTotalTimes = ['%.2f' % elem for elem in totalTimes]
myFormattedTotalTimes'输出(当输入的值为100时)为
^{pr2}$我需要使用列表中的值来创建一个直方图,其中x轴将显示赛道的名称,y轴将显示该赛道上的时间。Ive made quickly an excel histogram to help understand.
I have attempted but to no avail
for i in range (7):
pylab.hist([myFormattedTotalTimes[i]],7,[0,120])
pylab.show()
任何帮助都将不胜感激,我对这一点很迷茫。在
正如@John Doe所说,我想你需要一个条形图。在matplotlib example中,下面的代码可以满足您的需要
看起来像是,
相关问题 更多 >
编程相关推荐