how to set the bold font style in Plotly

Jason Li picture Jason Li · Oct 1, 2017 · Viewed 20.3k times · Source

When using the Plotly, I can set the title font in the layout part as follow.

titlefont=dict(size =14, color='black', family='Arial, sans-serif')

My question is How to set the font as Bold. Thanks

Answer

Maximilian Peters picture Maximilian Peters · Oct 1, 2017

If you are using Python you can add the <b> html tag to the title attribute and you are good.

You can add some more limited HTML styling such as italic as well, see example below.

enter image description here

import plotly
plotly.offline.init_notebook_mode()
data = [plotly.graph_objs.Bar(
            x=['giraffes', 'orangutans', 'monkeys'],
            y=[20, 14, 23]
    )]
layout = go.Layout(title='<b>Bold</b> <i>animals</i>')

fig = plotly.graph_objs.Figure(data=data, layout=layout)
plotly.offline.iplot(fig)