Could someone please tell me how to modify this Python code that uses matplotlib such that the width of the bars will stay constant regardless of how many scores are plotted? Thank you in advance!
# data to plot
n_groups = len(math_scores)
###print "im here", math_scores,verbal_scores
scores_readingwriting = verbal_scores
scores_math = math_scores
# create plot
fig, ax = plot.subplots()
index = np.arange(n_groups)
bar_width = 0.35
opacity = 0.8
rects1 = plot.bar(index, scores_readingwriting, bar_width,
alpha=opacity,
color='black',
label='R/W')
rects2 = plot.bar(index + bar_width, scores_math, bar_width,
alpha=opacity,
color='grey',
label='Math')
plot.xlabel('Date',size='14')
plot.ylabel('Scores',size='14')
plot.title(str(first_names[i])+' '+str(last_names[i])+"'s History",size='17')
num=len(scores)
###print datesofinterest
plot.xticks(index + bar_width/2, datesofinterest,size='12')
plot.yticks(size='12')
axes = plot.gca()
axes.set_ylim([200,800])
plot.legend()
plot.tight_layout()
fig.savefig('img'+str(student_ids[i])+'.png')
