【问题标题】:Plotting a histogram in python在python中绘制直方图
【发布时间】:2014-04-03 07:45:50
【问题描述】:

我用下面的代码计算了两个值

with open('paths_finished.tsv', 'rb') as tsvfile:
total = 0
count = 0
total2 = 0
count2 = 0
t = 0
for line in tsvfile:

   if '<;' in line:
        total += line.count(';')
        t += line.count('<;')
        count +=+1
   else:
        total2 += line.count(';') 
        count2 += 1

humanaverage = (total-t) / float(count)
computeraverage = total2 / float(count2)

print humanaverage

print computeraverage

输出:

8.33285158421

4.72252533125

如何在直方图中绘制这两个值?

【问题讨论】:

    标签: python matplotlib histogram


    【解决方案1】:

    你可以使用 bar:

    bar([0,1],[8.33285158421,4.72252533125],width=1)
    xticks([0.5,1.5],['humanaverage','computeraverage'])
    

    给予:

    另见the examples,如this one

    【讨论】:

      猜你喜欢
      • 2011-08-21
      • 2018-05-23
      • 2012-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-18
      相关资源
      最近更新 更多