def barGraph(data_count):
names, count_in = [], []
data_count = sorted(data_count.items(), key=operator.itemgetter(1), reverse=True)
for i in data_count:
names.append(i[0])
count_in.append(i[-1])
plt.rcdefaults()
fig, ax = plt.subplots()
y_pos = np.arange(len(names))
ax.barh(y_pos, count_in, align='center',
color='green', ecolor='black')
ax.set_yticks(y_pos)
ax.set_yticklabels(names)
ax.invert_yaxis() # labels read top-to-bottom
ax.set_xlabel('Categories')
ax.set_title('# of job titles in each category')
plt.show()
评论列表
文章目录