条形图

基本用法

import matplotlib.pyplot as plt

obj_list = obj_list[:100]
x_axis = range(len(obj_list))
y_axis = []
for x in obj_list:
    y_axis.append(x[1])
plt.figure(figsize=(16,10))
rects = plt.bar(left=x_axis, height=y_axis, width=0.6, color='red')
#plt.xticks(range(len(label_list)), label_list, fontsize=8)
#plt.title('motif num')
plt.legend()
# for rect in rects:
#     height = rect.get_height()
#     plt.text(rect.get_x() + rect.get_width() / 2, height+1, str(height), ha="center", va="bottom")
plt.grid(True)
plt.show()
原文地址:https://www.cnblogs.com/xumaomao/p/11934581.html