Learn
Recreate Graphs using Matplotlib!
Bar Chart with Error

First, we are going to look at the chart called bar_chart.png.

bar_chart

The data you will need to recreate this chart is in the lists past_years_averages, years, and error.

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

Instructions

1.

First, create a figure of width 10 and height 8.

2.

Plot the blue bars, which have the heights listed in past_years_averages.

3.

Add error bars of cap size 5 and heights corresponding to the list error.

4.

Set the axis to go from -0.5 to 6.5 on the x-axis and 70 to 95 on the y-axis.

5.

Create an ax object using plt.subplot(). Use ax to set the x-axis ticks to be range(len(years)) and the x-axis labels to be the years list.

6.

Add the title "Final Exam Averages", x-axis label "Year", and y-axis label "Test average".

7.

Save your figure to a file called my_bar_chart.png.

Folder Icon

Sign up to start coding

Already have an account?