WeCodeAcademy

Building a Small Dashboard

A dashboard is several charts arranged so that one look answers several questions. Plan the grid first: decide which question each panel answers, give each a clear title, share axes where the unit is the same, and keep the colours consistent.

plt.subplots(2, 2, figsize=(11, 7)) gives four panels, indexed axs[0][0], axs[0][1], axs[1][0], axs[1][1]. Finish with fig.suptitle(...) for an overall headline and fig.tight_layout() to space the panels.

Examplepython
Open in editor »
Quick check

What does `fig.tight_layout()` do?

Your turn: write the code

Make a 2 by 2 figure, draw a bar chart in the top-left panel, and print the number of axes and the number of bars on one line separated by a space (use len(fig.axes) and len(axs[0][0].patches)).

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.