Skip to Content
Learn
Recreate Graphs using Matplotlib!
Two Histograms on a Plot

Now, we are going to look at the chart called histograms.png. This displays the breakdown of final exam scores between your first year of teaching vs your second year of teaching.

histogram

The data you will need to recreate this chart is in the lists exam_scores1 and exam_scores2.

Save your recreated chart to a file called my_histogram.png.

Instructions

1.

Create a figure of width 10 and height 8.

2.

Make a histogram of the exam_scores1, normalized, with 12 bins.

3.

Make a histogram of the exam_scores2, normalized, with 12 bins.

4.

Add histtype = 'step' to each plt.hist call, in order to make these histograms more visible.

We can also make the lines thicker by setting the linewidth inside the calls to plt.hist.

Let’s set the linewidth to be 2 for both histograms.

5.

Create a legend showing that the first set of data is "1st Yr Teaching" and the second set of data is "2nd Yr Teaching".

6.

Add the title, x-axis label, and y-axis label that you see on the final graph.

7.

Save your figure to a file called my_histogram.png.

Folder Icon

Sign up to start coding

Already have an account?