Learn

Now, we are going to look at the chart called line_graph.png. This displays the relationship between the time students say they studied and the scores they received on their final exams.

fill_between

The data you will need to recreate this chart is in the lists hours_reported and exam_scores.

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

Instructions

1.

Create a figure of width 10 and height 8.

2.

Plot the exam_scores on the x-axis and the hours_reported on the y-axis, with a linewidth of 2.

3.

Let’s assume the error on students’ reporting of their hours studying is 20%.

Create a list hours_lower_bound, which has the elements of hours_reported minus 20%, and a list hours_upper_bound, which has the elements of hours_reported plus 20%.

You can do this with a list comprehension that looks like:

y_lower_bound = [element - (element * error_in_decimal) for element in original_list_of_y_values]
4.

Shade the area between hours_lower_bound and hours_upper_bound with an alpha of 0.2.

5.

Give the plot the title 'Time spent studying vs final exam scores', x-axis label 'Score', and y-axis label 'Hours studying (self-reported)'.

6.

Save your figure to a file called my_line_graph.png.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?