How to Change the Title Font Size in Plotly

Plotly offers extensive customization options for your plots, including adjusting the title font size. This guide demonstrates two methods to achieve this: using the layout argument and the update_layout method.

Method 1: Using the layout argument

To directly change the title font size at the time of plot creation, include a title_font size specification within the layout dictionary. This is a dictionary that allows you to modify various aspects of your plot’s layout. To set the title font size to 24, for example:

import as px
df =
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species",
title="Iris Dataset", 

This example creates a scatter plot from the Iris dataset with a title font size of 24.

See also  Creating Interactive Bar Charts with Plotly in Python

Method 2: Using the update_layout method

The update_layout method provides a flexible approach for tweaking your plot’s appearance, including the title font size, after the plot has been created. You can specify the title font size by passing a dictionary to the title_font argument, like so:

import as px

df =
fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
fig.update_layout(title="Iris Dataset", title_font={"size": 24})

In this example, the update_layout method is used to set the title font size to 24 for a scatter plot of the Iris dataset.

See also  How to add vertical line in Plotly

These methods provide flexibility in customizing the appearance of your Plotly plots, ensuring they meet your presentation or publication standards.