Title and Axes

Customizing titles and axes

In this course, we will use the fig.update_layout() method to adjust the aesthetic element of our plot(s). We can customize the title, x-axis, y-axis, and more. This becomes exceptionally powerful when addressing client demands and business needs.

We will start by using a customer churn dataset.

Updating the title

To adjust only the title text, we can simply pass a string to the title keyword argument in the fig.update_layout() method. The same applies to the x and y axes, where we can simply pass a string to the xaxis_title and yaxis_title keyword arguments.


In the plot below, we have a box plot that investigates the spread of the peoples’ ages in each country. Hence it is suitable to give this graph the title of Ages by Country. We’ll also label the x-axis as Country and the y-axis as Age. Pay close attention to the code snippet below:

fig.update_layout(title='Ages by Country', xaxis_title='Country', yaxis_title='Age')

Get hands-on with 1200+ tech skills courses.