Now, we are going to look at the chart called
stacked-bars.png. This graph displays the breakdown of students who got As, Bs, Cs, Ds, and Fs in each unit.
The data you will need to recreate this chart is in the lists
Save your recreated chart to a file called
Bs bars will go on top of the
As bars, but at what heights will the
Fs bars start?
The bottom of the bars representing the
Cs will be at the height of the
As plus the
Bs. We can do this in NumPy (a scientific computing package for Python) with the
c_bottom, the starting heights for the
Cs, will be:
c_bottom = np.add(As, Bs)
Underneath the definition of
d_bottom (where the
Cs end), and
f_bottom (where the
Create a figure of width
10 and height
Fs. Give each one the appropriate
bottom list that will stack them on top of each other.
Create a set of axes and save them to
Set the x-ticks to be
Set the x-tick labels to be the
Give the plot the title you see in the final graph, and the same x-axis label and y-axis label.
Save your figure to a file called