When going through the first instruction I was confused as of what what to do. It instructs me to make two variable lists that have already been created previously. So instead of using the function given I just pressed next and it worked fine. Is there a reason to follow the first instruction other than to get used to the bar format or is it a mistake to have the list variables there in the first place?
In case someone is wondering as by following the instructions you end up with a different graph, the axes are something like this:
plt.axis([0, 10, 70, 90])
10 because the final bar is centered on 9.6, and the bars are 0.8 in width; the value at [-1] index of x_values for the last bar in your graph, + half the width of your bars.
In case you are having trouble with point 5, you can use this function to calculate the position of the x ticks; works with any number of adjacent bars.
def x_ticks(t, w, d):
return [t*element + (w * (t + 1) * .5) for element in range(d)]
middle_x = x_ticks(2, 0.8, len(middle_school_a))
Nice! I had trouble understanding what x-values to put here; I ended up using plt.ylim(70, 90), which accomplished the same result without the guessing.
I think whoever made this exercise forgot to include a step that involves plt.axis() because the final graph does not look like the one we’re supposed to make.