Setting Subplot Title Font Sizes

Hi,

When using make_subplots, how can I change the font size of the title? I’ve tried numerous combinations (different words involving title-font-size, syntax, etc.) of the below without success. Lots of syntax or unexpected keyword argument errors. I searched the forum, as well as some of the documentation (help(make_subplots), creating/updating figures, subplots, setting font/etc.). Again, I didn’t have any luck, but I’m sure I’m overlooking something simple. I’m using Plotly 4.11. Any assistance is appreciated.


kwargs={‘title_font’: dict(size=24)}
fig = make_subplots(row=2, col=1, subplot_titles=(“Title A”, “Title B”), **kwargs)

Apparently subplot titles are annotations (Subplot font size is hardcoded to 16pt · Issue #985 · plotly/plotly.py · GitHub)

Hence you can update the subplots font size using:

fig.update_annotations(font_size=12)

Hope this helps,

Cheers

4 Likes

Thank you, your suggestion worked. I also appreciated the GitHub link, which gave me some additional background. I wished that this functionality was a keyword parameter, since other annotations might be present on a chart and doing a repeated call to “reset” the font size isn’t efficient. Anyhow, I’m glad to have a workaround. Thanks again!

1 Like

Probably it is late to add the answer, but someone else might use it.
I found the nice solution to use fig.for_each_annotation(lambda a: a.update(text=f'<b>{a.text}</b>')), This way you can update all annotations at once.
These will update font for all Title in sublots fig.update_annotations(font=dict(family="Helvetica", size=12))

3 Likes