# Plotly Font Size, Titles, and Axis Titles

> How to change font size in Plotly with update_layout(font_size=...), set chart and axis titles, add a subtitle, and center, wrap or style titles.

Source: https://www.pythoncharts.com/plotly/plotly-font-size-titles/ | Published: 2026-11-27 | Author: Alex Scott | Category: Plotly | Tags: plotly, plotly express, font size, title, axis titles, layout

To change every font size in a Plotly chart at once, use `fig.update_layout(font_size=16)`. For one element, set it directly: `title_font_size` for the chart title, `fig.update_xaxes(title_font_size=...)` for an axis title, and `fig.update_xaxes(tickfont_size=...)` for tick labels.

## Quick Example

```python
import numpy as np
import pandas as pd
import plotly.express as px

rng = np.random.default_rng(71)
weeks = pd.date_range("2026-03-02", periods=26, freq="W-MON")
season = np.linspace(0, 1, 26)
riders = pd.concat([
    pd.DataFrame({"week": weeks, "route": route,
                  "passengers": (base + lift * season ** 1.5
                                 + rng.normal(0, 140, 26)).round()})
    for route, base, lift in [("North Harbor", 3100, 2600), ("Island Loop", 1900, 3100)]
])

fig = px.line(riders, x="week", y="passengers", color="route",
              color_discrete_map={"North Harbor": "#0e7490", "Island Loop": "#ea580c"},
              labels={"week": "Week", "passengers": "Passengers", "route": "Route"})
fig.update_layout(
    template="plotly_white",
    font_size=15,                      # base size for everything
    title=dict(text="Weekly ferry ridership", font_size=26,
               subtitle=dict(text="March to August 2026, sample data",
                             font=dict(size=15, color="#6b7280"))),
    margin_t=90,
)
fig.update_xaxes(title_font_size=18, tickfont_size=13)
fig.update_yaxes(title_font_size=18, tickfont_size=13)
fig.show()
```

![Plotly line chart of weekly passengers on two ferry routes from March to August 2026, with a large title, a gray subtitle and larger axis titles](https://www.pythoncharts.com/plotly/plotly-font-size-titles/images/plotly-font-size-quick-example.png)

The title is 26px, the axis titles 18px, the tick labels 13px, and the legend picks up the base size of 15px. The code targets Plotly 6.x.

## Which Setting Controls Which Text?

| Text | Setting | Default size |
|---|---|---|
| Everything | `update_layout(font_size=...)` | 12 |
| Chart title | `update_layout(title_font_size=...)` | 17 (1.4 × base) |
| Subtitle | `update_layout(title_subtitle_font_size=...)` | 12 (base) |
| Axis titles | `update_xaxes(title_font_size=...)` | 14 (1.2 × base) |
| Tick labels | `update_xaxes(tickfont_size=...)` | 12 (base) |
| Legend entries | `update_layout(legend_font_size=...)` | 12 (base) |
| Legend title | `update_layout(legend_title_font_size=...)` | 14 (1.2 × base) |
| Hover box | `update_layout(hoverlabel_font_size=...)` | follows base |
| Facet titles and annotations | `update_annotations(font_size=...)` | 12 (base) |
| Text on bars or points | `update_traces(textfont_size=...)` | follows base |

Underscores are shorthand for nesting: `title_font_size=26` is the same as `title=dict(font=dict(size=26))`. Every font object also takes `family`, `color`, `weight` and `style`.

## Change All Font Sizes at Once

Raising the base size scales titles with it, because they default to a multiple of it. This is usually the only change needed for a slide or a report.

```python
fig = px.line(riders, x="week", y="passengers", color="route",
              title="font_size=20 scales everything",
              color_discrete_sequence=["#0e7490", "#ea580c"])
fig.update_layout(template="plotly_white", font_size=20)
fig.show()
```

![Line chart of two ferry routes with a base font size of 20, showing large title, axis titles, tick labels and legend](https://www.pythoncharts.com/plotly/plotly-font-size-titles/images/plotly-font-size-base.png)

At a base of 20, the title draws at 28px and the axis titles at 24px.

## Set the Title and Axis Titles

In Plotly Express, `title=`, `subtitle=` and `labels=` cover most cases. After the figure exists, use `title_text`, which works for the chart and for each axis.

```python
fig = px.line(riders, x="week", y="passengers", color="route",
              color_discrete_sequence=["#0e7490", "#ea580c"])
fig.update_layout(template="plotly_white", title_text="Island Loop closes the gap",
                  legend_title_text="")
fig.update_xaxes(title_text=None)                       # remove the x-axis title
fig.update_yaxes(title_text="Passengers per week", title_standoff=15)
fig.show()
```

![Ferry ridership line chart with a new chart title, no x-axis title, a custom y-axis title and no legend title](https://www.pythoncharts.com/plotly/plotly-font-size-titles/images/plotly-font-size-titles.png)

- `title_standoff` is the gap in pixels between the tick labels and the axis title.
- `title_text=None` removes an axis title, and the plot area grows into the space.
- `subtitle=` in Plotly Express was added in Plotly 6.0. The `title.subtitle` layout setting works from 5.23.

If you have old code using `titlefont` or `title_font` as a top-level layout key, note that Plotly 6 removed `titlefont`. Use `title_font` on the axis, or `title=dict(text=..., font=...)`.

## Center the Title

Titles sit near the left edge by default (`x=0.05`). Set `title_x=0.5` with `title_xanchor="center"` to center it. The position is relative to the whole figure. Add `title_xref="paper"` to measure from the plot area instead, which matters when a legend takes up space on the right.

```python
fig = px.line(riders, x="week", y="passengers", color="route",
              title="Centered over the plot area",
              color_discrete_sequence=["#0e7490", "#ea580c"])
fig.update_layout(template="plotly_white", title_x=0.5, title_xanchor="center",
                  title_xref="paper")
fig.show()
```

![Ferry ridership line chart with the title centered above the plot area and the legend to the right](https://www.pythoncharts.com/plotly/plotly-font-size-titles/images/plotly-font-size-center.png)

To align a left title with the y-axis instead, use `title_x=0` and `title_xref="paper"`.

## Style Titles: Bold, Color, and Font Family

`weight`, `style` and `color` live on the font object. `weight` needs Plotly 5.22 or later. Title strings also accept a few HTML tags (`<b>`, `<i>`, `<sup>`, `<br>` and `<span style="...">`), which is the way to style part of a title.

```python
fig = px.line(riders, x="week", y="passengers", color="route",
              color_discrete_sequence=["#0e7490", "#ea580c"])
fig.update_layout(
    template="plotly_white",
    font_family="Georgia, serif",
    title=dict(text=('<span style="color:#ea580c">Island Loop</span> vs '
                     '<span style="color:#0e7490">North Harbor</span>'),
               font=dict(size=24, weight="bold")),
    showlegend=False,
)
fig.update_yaxes(title_font=dict(color="#6b7280", style="italic"))
fig.show()
```

![Ferry chart in a serif font with the route names in the title colored to match their lines, replacing the legend](https://www.pythoncharts.com/plotly/plotly-font-size-titles/images/plotly-font-size-style.png)

The font has to be installed on the viewer's machine, so list a fallback such as `serif` or `sans-serif`.

## Wrap a Long Title

Plotly doesn't wrap titles automatically. Break lines with `<br>`, pin the top of the title with `y` and `yanchor="top"`, and make room for the second line with a larger top margin.

```python
fig = px.line(riders, x="week", y="passengers", color="route",
              color_discrete_sequence=["#0e7490", "#ea580c"])
fig.update_layout(
    template="plotly_white",
    title=dict(text="Weekly passengers on the two summer routes climbed<br>"
                    "through spring and peaked in late August",
               font_size=22, y=0.95, yanchor="top"),
    margin_t=110,
)
fig.show()
```

![Ferry chart with a long title broken onto two lines above the plot area](https://www.pythoncharts.com/plotly/plotly-font-size-titles/images/plotly-font-size-wrap.png)

For titles built from data, `"<br>".join(textwrap.wrap(title, 55))` does the breaking for you. `title_automargin=True` is meant to grow the margin for you, but with this two-line title in Plotly 6.9 the first line was still cut off, so check the output if you rely on it.

## Hover Text, Bar Labels, and Facet Titles

These three have their own settings.

```python
totals = riders.assign(month=riders["week"].dt.strftime("%b")).query("month in ['Mar', 'May', 'Jul']")
totals = totals.groupby(["route", "month"], as_index=False, sort=False)["passengers"].sum()

fig = px.bar(totals, x="month", y="passengers", facet_col="route", text_auto=".2s",
             title="Passengers in three months",
             color_discrete_sequence=["#4338ca"])
fig.update_traces(textfont_size=16, textposition="inside")
fig.update_annotations(font_size=18)          # the "route=..." facet titles
fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
fig.update_layout(hoverlabel_font_size=16, uniformtext=dict(minsize=16, mode="show"))
fig.show()
```

![Two faceted bar charts of passengers in March, May and July for each ferry route, with large facet titles and large value labels inside the bars](https://www.pythoncharts.com/plotly/plotly-font-size-titles/images/plotly-font-size-bars.png)

Plotly shrinks bar text to fit narrow bars, so `textfont_size` can appear to do nothing. `uniformtext` sets a floor: `mode="show"` keeps every label at `minsize`, and `mode="hide"` drops the ones that don't fit.

## Practical Tips

- To apply sizes to every chart in a script, set them on a template: `pio.templates["plotly_white"].layout.font.size = 15`.
- Exporting for print or slides? Increase `scale` in `fig.write_image()` for sharpness and `font_size` for legibility. They're separate, as covered in [exporting static images with Kaleido](https://www.pythoncharts.com/plotly/plotly-export-static-images-with-kaleido/).
- Larger tick labels may overlap on narrow screens. [Rotate the tick labels](https://www.pythoncharts.com/plotly/plotly-rotate-tick-labels-plotly-express/) or format them shorter.

## Similar Topics

- [How to Position the Legend in Plotly](https://www.pythoncharts.com/plotly/plotly-legend-position/)
- [How to Add Custom Annotations in Plotly](https://www.pythoncharts.com/plotly/plotly-add-custom-annotations/)
- [Plotly Express Line Charts with px.line](https://www.pythoncharts.com/plotly/plotly-express-line-charts/)
