我画了3个条形图,问题解决了。在import matplotlib.pyplot as plt;plt.rcdefaults()
from numpy.random import rand
from numpy import arange
import numpy as np
def libra_execution_time():
data = np.genfromtxt('C:\\programming\\Python27\\libra_graphs\\File\\histogram.csv',delimiter=',')
hash_diff,key_diff,binary_diff = 0,0,0
hash_time_lst,key_time_lst,binary_time_lst = [],[],[]
for row in data:
if not np.isnan(row[7]):
hash_diff = row[7]-hash_diff
hash_time_lst.append(hash_diff)
for row in data:
if not np.isnan(row[8]):
key_diff = row[8]-key_diff
key_time_lst.append(key_diff)
for row in data:
if not np.isnan(row[9]):
binary_diff = row[9]-binary_diff
binary_time_lst.append(binary_diff)
print "#Hash Partitioner ->" ,hash_time_lst,len(hash_time_lst)
print "#Key Field Partitioenr ->", key_time_lst,len(key_time_lst)
print "#Binary Partitioner ->",binary_time_lst,len(binary_time_lst)
#x_lst = (hash_time_lst + key_time_lst + binary_time_lst)
#print x_lst
job_time = {"Hash Time":hash_time_lst,"Key_Time":key_time_lst,"Binary Time":binary_time_lst}
print job_time
print job_time.keys(),job_time.values()
y_pos = np.arange(len(job_time.values()))
print "Y position",y_pos
val = np.array(job_time.values())
print val
plt.barh(y_pos,val ,align='center',height = 0.5 ,color=('r','y','g'))
plt.yticks(y_pos,job_time.keys())
plt.xlabel('Time(seconds)')
plt.ylabel('Performance ->')
plt.title('Job Execution LIBRA')
plt.show()
libra_execution_time()