简体   繁体   中英

Plotting a histogram in python

i have calculated two valuse with the code below

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

output:

8.33285158421

4.72252533125

How do i plot these two walue in a histogram?

You could use bar:

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

Gives:

在此处输入图片说明

See also the examples , like this one .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM