How to set general font for graph with Plotly?


When plotting a graph with Plotly, is there a way to set a font for the whole figure at once (so that you don’t have to set it individually for each element in your graph)?

For MatPlotLib this is done with:

matplotlib.pyplot.rcparams[""] = "Calibri"

For Plotly this is done with:

Asked By: Matthi9000



You should be able to do this with = 'Arial'

This will be used as the default for all other fig.<anything> unless you explicitly override them.

Here is the documentation link:

If you want this set Plotly-wise you can use a Template:

Answered By: nicolaskruchten

If you have a font (or any style really) that you want to apply to many figures

import plotly.figure_factory as ff

class Plot():
    def __init__(self):
        self.my_template = dict(

    def some_plot(self):
        #fig = ...
        return fig
Answered By: Kermit

That can be done editing templates:

import as pio
import plotly.graph_objects as go

pio.templates["my_modification"] = go.layout.Template(
    layout=dict(font={"size": 20})

# Then combine your modification with any of the 
# available themes like this:
pio.templates.default = "plotly_white+my_modification"
Answered By: Soren
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.