Skip to Content
Learn
Recreate Graphs using Matplotlib!
Side By Side Bars

Now, we are going to look at the chart called `side-by-side.png`. This displays the differences in average test scores between students who went to two different middle schools before enrolling in your high school.

The data you will need to recreate this chart is in the lists `middle_school_a`, `middle_school_b`, and `unit_topics`.

Save your recreated chart to a file called `my_side_by_side.png`.

### Instructions

1.

Using `create_x`, make the lists `school_a_x` and `school_b_x` which will determine where to put the bars for Middle School A and Middle School B along the x-axis.

2.

Create a figure of width `10` and height `8`.

3.

Create a set of axes and save them to `ax`.

4.

Plot a set of bars representing `middle_school_a` and a set representing `middle_school_b` next to each other on the same graph.

5.

Create a new list of x-values called `middle_x`, which are the values in the middle of `school_a_x` and `school_b_x`. This is where we will place the x-ticks. Look at the final graph to see this placement.

6.

Set the x-ticks to be the `middle_x` list.

7.

Set the x-tick labels to be the list `unit_topics`.

8.

Create a legend, as shown in the final graph, that labels the first set of bars `Middle School A` and the second set of bars `Middle School B`.

9.

Create a title (“Test Averages on Different Units”), x-axis label (“Unit”), and y-axis label (“Test Average”).

10.

Save your figure to a file called `my_side_by_side.png`.

# Sign up to start coding

## Or sign up using:

Already have an account?