Change title color using html

If I want to bold a title I can do this

layout = go.Layout(title='Crosby <b>87</b> ')

However, if I want to change part of the title to another color I was thinking of doing

layout = go.Layout(title='Crosby <font color="red">87</font> ')

But it doesnโ€™t work.

Any ideas?

1 Like

@alexpetit12 You can set the font color for the entire title not only for substrings of it.

layout=go.layout(title =  dict(text ='Your title',
                               font =dict(family='Sherif',
                               size=14,
                               color = 'red')),
...
)

for more title attributes see https://plot.ly/python/reference/#layout-title.

Hi @alexpetit12,

For a little context, plotly.js doesnโ€™t support arbitrary HTML markup in labels. Here is a description of the subset that is supported https://help.plot.ly/adding-HTML-and-links-to-charts/#step-2-the-essentials. Font colors must be specified in the font property as @empet described.

-Jon

2 Likes