WeCodeAcademy

Charts Straight from Pandas

Pandas has plotting built in, so a table becomes a chart in one line: df.plot(kind='bar', x='region', y='sales'). It draws with matplotlib underneath and returns the axes, so you can keep customising with set_title and the other methods you know.

Use df.plot for quick looks at your data, and drop down to matplotlib directly when you need full control of the layout.

Examplepython
Open in editor »
Quick check

What does `df.plot(...)` return?

Your turn: write the code

Draw a bar chart of df from the 'city' and 'pop' columns with the title 'Population', then print the title (use print(ax.get_title())).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.