Python 重叠拟图条形图?

Python 重叠拟图条形图?,python,matplotlib,Python,Matplotlib,我正在学习python中的matplot,我想制作一个带有并排条的条形图。由于某种原因,我的情节目前是重叠的 将numpy导入为np 将matplotlib.pyplot作为plt导入 n_组=7 意思是_frank=(82,75,86,63,90,73,88) 意思是_alex=(91,92,80,73,83,91,71) 指乔=(72,42,50,33,63,34,54) 图=plt.图() ax=图添加_子批次(111) 指数=np.arange(n组) 钢筋宽度=0.27 不透明度=0

我正在学习python中的matplot,我想制作一个带有并排条的条形图。由于某种原因,我的情节目前是重叠的

将numpy导入为np
将matplotlib.pyplot作为plt导入
n_组=7
意思是_frank=(82,75,86,63,90,73,88)
意思是_alex=(91,92,80,73,83,91,71)
指乔=(72,42,50,33,63,34,54)
图=plt.图()
ax=图添加_子批次(111)
指数=np.arange(n组)
钢筋宽度=0.27
不透明度=0.8
rects1=ax.bar(索引,表示宽度、宽度、颜色、标签)
rects2=ax.bar(索引,表示“alex”,bar\u width,color='g',label=“alex”)
rects3=ax.bar(索引,表示“joe”,bar\u width,color='r',label=“joe”)
plt.ylabel(“分数”)
课程名称(“考试分数”)

plt.xticks([0,5,6],“Assignments-->”,“@ImportanceofBeingErnest帮助创建此链接:


必须修改索引参数以防止重叠。

检查是否正确!这是bar函数中的第一个参数。谢谢!
import numpy as np
import matplotlib.pyplot as plt

n_groups = 7
means_frank = (82, 75, 86, 63, 90, 73 ,88)
means_alex = (91, 92, 80, 73, 83, 91, 71)
means_joe = (72, 42, 50, 33, 63, 34, 54)


fig = plt.figure()
ax = fig.add_subplot(111)


index = np.arange(n_groups)
bar_width = 0.27
opacity = 0.8

rects1 = ax.bar(index,means_frank,bar_width,color='b', label="Frank")

rects2 = ax.bar(index,means_alex,bar_width,color='g', label="Alex")

rects3 = ax.bar(index,means_joe,bar_width,color='r', label="Joe")

plt.ylabel('Scores')
plt.title('Test Scores')
plt.xticks([0, 5, 6], ["Assignments -->", "<-- Midterm", "Final"])
plt.legend()

plt.tight_layout()


plt.show()