[英]how to draw multiple bar plot using matplotlib
嘗試這個,...
import matplotlib.pyplot as plt
import numpy as np
labels = ['n', '0', 'p']
men_means = [2000, 1000, 23000]
women_means = [20000, 4500, 120000]
women_meanT = [8000, 2500, 76000]
x = np.arange(len(labels)) # the label locations
width = 0.35 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, men_means, width, label='1')
rects2 = ax.bar(x + width/2, women_means, width, label='2')
rects2 = ax.bar(x+width/2+width, women_meanT, width, label='3')
# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_xticks(x, labels)
ax.legend()
fig.tight_layout()
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.