Font styling in Python using custom font

Hello everyone,

I am trying to edit the font title of my graph in Plotly. I’ve read this article on how to change the title font: https://plot.ly/python/font/ but I can’t manage to make it work with the font I want (Franklin Gothic) which is installed on my computer. I don’t have any error but my title is written with the default font.

Is there a way to find all the available fonts in Plotly? And is it possible to add new custom fonts?

I am working with plotly 3.3.0 on jupyter notebook.

Thanks for your help!

1 Like

Hi @julied20, The font you set in your code is displayed only if it’s installed on your computer.

I ran this code:

import plotly.graph_objs as go

data = [
    go.Scatter(
        x=[0, 1, 2, 3, 4, 5, 6, 7, 8],
        y=[0, 1, 2, 3, 4, 5, 6, 7, 8]
    )
]
layout = go.Layout(width=500, height=300,
    title='Franklin Gothic Font',
    font=dict(family="Franklin Gothic", size=18)
)
fig = go.FigureWidget(data=data, layout=layout)
fig

and here is the plot:

It seems to be Franklin Gothic. Hence it is installed on my system.

I’m encountering the same problem. I have the custom font I want installed on my server on EC2, but figures fail to render the custom font.

The custom font renders correctly on my local machine but not on the server. Is there a way to check what fonts are available to plotly? And where it tried to load them from?

1 Like

Hey empet, do you know a way of setting the font only for the title? (without affecting the axes)

Hi @HC-85
Yes, I know: :slight_smile:

import plotly.graph_objects as go
import numpy as np
fig=go.Figure(go.Scatter(x=np.arange(5), y=np.random.rand(5)))
fig.update_layout(width=600, height=400,
                 title=dict(text="This is my title",
                            x=0.5, y=0.93,
                            font_family="Open Sherif",
                            font_size=20,
                            font_color="red"),
                 font_family="Open Sherif",
                 font_size=10)

title

Were you able to solve this problem? I am also having trouble finding which fonts are actually available and how to support custom fonts (*.ttf e.g.)
@empet ?

@charelstoncrabb
I’m sorry, but I don’t know such a “secret”. Maybe someone skilled in web programming could give you an advice.

1 Like