Matplotlib Labels and Title

Matplotlib Labels and 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.

Example

Add labels to the x- and y-axis:

Result:

Try it Yourself »


Create a Title for a Plot

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

Example

Add a plot title and labels for the x- and y-axis:

Result:

Try it Yourself »


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.

Example

Set font properties for the title and labels:

Result:

Try it Yourself »


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’.

Example

Position the title to the left:

Result:

Try it Yourself »

ArmenianEnglish