9

For instance, for a graph such as this made with basic plotly code enter image description here

What is the font used here?

2 Answers 2

13

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. If you don't have Open Sans, Plotly will try to use Verdana, and in absence of that, Arial. If no font from any of those families is available, Plotly will default to using any sans-serif available on your system.

Based solely on the shape of the lowercase a in the title of the plot you posted, it appears that your plot was rendered using Open Sans.

The relevant passage from the Pyplot documentation is quoted below (emphasis mine).

font

Code: fig.update_layout(font=dict(...))
Type: dict containing one or more of the keys listed below.

Sets the global font. Note that fonts used in traces and other layout components inherit from the global font.

family

Code: fig.update_layout(font_family=<VALUE>)
Type: string
Default: ""Open Sans", verdana, arial, sans-serif"

HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system.

1
2

Based on Plotly's documentation:

You can set the figure-wide font with the layout.font attribute, which will apply to all titles and tick labels, but this can be overridden for specific plot items like individual axes and legend titles etc. In the following figure, we set the figure-wide font to Courier New in blue, and then override this for certain parts of the figure.

import plotly.express as px

df = px.data.iris()
fig = px.scatter(df, x="sepal_length", y="sepal_width", color="species",
                title="Playing with Fonts")
fig.update_layout(
    font_family="Courier New",
    font_color="blue",
    title_font_family="Times New Roman",
    title_font_color="red",
    legend_title_font_color="green"
)
fig.update_xaxes(title_font_family="Arial")
fig.show()

But by default, it really depends on the browser rendering the output. HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates.

enter image description here

1
  • 1
    Doesn't answer the question. Question asked which font specific is default. Not how to change it.
    – nordmanden
    Nov 23, 2022 at 8:47

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.