oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Stacked Bars #500

Open oldoc63 opened 1 year ago

oldoc63 commented 1 year ago

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 As, Bs, Cs, Ds, Fs and unit_topics. Save your recreated chart to a file called my_stacked_bar.png.

oldoc63 commented 1 year ago
  1. The Bs bars will go on top of the As bars, but at what heights will the Cs, Ds, and Fs bars start? The bottom of the bars representing the Cs will be at the height of the As plus the Bs. We cna do this in NumPy (a scientific computing package for Python) with the np.add function. c_botton, the starting heights for the Cs, will be:
oldoc63 commented 1 year ago

Underneath the definition of c_bottom, define d_bottom (where the Cs end), and f_bottom (where the Ds end).

oldoc63 commented 1 year ago
  1. Create a figure of width 10 and height 8.
oldoc63 commented 1 year ago
  1. Plot the As, Bs, Cs, Ds and Fs. Give each one the appropriate bottom list that will stack them on top of each other.
oldoc63 commented 1 year ago
  1. Create a set of axes and save them to ax.
  2. Set the x-ticks to be range(len(unit_topics)).
  3. Set the x-tick labels to be the unit_topics.
  4. Give the plot the title you see in the final graph, and the same x-axis label and y-axis label.
  5. Save your figure to a file called my_stacked_bar.png.