Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set the bold font style in Plotly

Tags:

fonts

plotly

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

like image 508
Jason Li Avatar asked Oct 01 '17 13:10

Jason Li


People also ask

How do I make text bold in Plotly?

One method for getting bold text is to change the font to Arial Black (or other bold font) which should be available on most systems. This method will scale a little easier to axes and other elements.

What is the default font in Plotly?

The default font family spec is "Open Sans", verdana, arial, sans-serif , as listed in Python Figure Reference: layout from the Plotly documentation. The precise font selected depends on which fonts you have installed on your system. If Open Sans is available, that font will be selected.

Which CSS property is used to make the text bolder?

The font-weight CSS property sets the weight (or boldness) of the font.


1 Answers

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)
like image 103
Maximilian Peters Avatar answered Sep 22 '22 05:09

Maximilian Peters