WeCodeAcademy

Titles and Axis Labels

A chart nobody can read has failed, however good the data. Three lines fix most of the problem: a title that says what the chart shows, and a label on each axis that says what is measured and in which unit.

Use ax.set_title(...), ax.set_xlabel(...) and ax.set_ylabel(...). A strong title states the finding ("Sales doubled in six months"), not just the topic ("Sales"). Put units in the label, for example "Revenue (GH cedis)".

Examplepython
Open in editor »
Quick check

Which call sets the label under the horizontal axis?

Your turn: write the code

Give the chart the title 'Rainfall', the x label 'Month' and the y label 'Millimetres', then print the three texts on separate lines (use ax.get_title(), ax.get_xlabel(), ax.get_ylabel()).

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.