FAQ: Recreate graphs using Matplotlib! - Side By Side Bars

This community-built FAQ covers the “Side By Side Bars” exercise from the lesson “Recreate graphs using Matplotlib!”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

Data Visualization in Python

FAQs on the exercise Side By Side Bars

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

When going through the first instruction I was confused as of what what to do. It instructs me to make two variable lists that have already been created previously. So instead of using the function given I just pressed next and it worked fine. Is there a reason to follow the first instruction other than to get used to the bar format or is it a mistake to have the list variables there in the first place?

Link to lesson


It seems to be a mistake because the two lists under create_x disappeared when I reset the exercise.

In case someone is wondering as by following the instructions you end up with a different graph, the axes are something like this:

plt.axis([0, 10, 70, 90])

10 because the final bar is centered on 9.6, and the bars are 0.8 in width; the value at [-1] index of x_values for the last bar in your graph, + half the width of your bars.


I would like to have a reminder on how to create a figure, for a reason that I don’t know there is no example in the cheat sheet.



I find this procedure extremely long and confusing, I found this way much more simpler and easier to implement.

import pandas as pd

unit_topics = ["Limits", "Derivatives", "Integrals", "Diff Eq", "Applications"]
middle_school_a = [80, 85, 84, 83, 86]
middle_school_b = [73, 78, 77, 82, 86]

df = pd.DataFrame(
    dict(middle_school_a=middle_school_a, middle_school_b=middle_school_b),

ax = df.plot.bar(title="Test Averages on Different Units", rot=0)