Python Tutorials · Python Matplotlib

Matplotlib Labels

Learn all about Matplotlib Labels in this comprehensive tutorial.

5 min read intermediate
  • With Pyplot, you can use the xlabel() and ylabel() functions to set a label for the x- and y-axis.
  • With Pyplot, you can use the title() function to set a title for the plot.
  • You can use the fontdict parameter in xlabel(), ylabel(), and title() to set font properties for the title and labels.
  • You can use the loc parameter in title() to position the title.

Create Labels for a Plot

With Pyplot, you can use the xlabel() and ylabel() functions to set a label for the x- and y-axis.

python

Create a Title for a Plot

With Pyplot, you can use the title() function to set a title for the plot.

python

Set Font Properties for Title and Labels

You can use the fontdict parameter in xlabel(), ylabel(), and title() to set font properties for the title and labels.

python

Position the Title

You can use the loc parameter in title() to position the title.

Legal values are: 'left', 'right', and 'center'. Default value is 'center'.

python

Module quiz

2 questions
1

Which of the following is true about Matplotlib Labels?

2

What is the most common pitfall when working with Matplotlib Labels?

Answer all questions to submit.