Skip to content

Commit

Permalink
add font example
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamConnors committed Apr 24, 2024
1 parent f60b7f0 commit 025eea7
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions doc/python/figure-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jupyter:
extension: .md
format_name: markdown
format_version: '1.3'
jupytext_version: 1.14.5
jupytext_version: 1.16.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand All @@ -20,7 +20,7 @@ jupyter:
name: python
nbconvert_exporter: python
pygments_lexer: ipython3
version: 3.10.9
version: 3.10.11
plotly:
description: How to set the global font, title, legend-entries, and axis-titles
in python.
Expand Down Expand Up @@ -159,6 +159,60 @@ fig.update_layout(
fig.show()
```

### Configuring Font Variant, Style, and Weight

*New in 5.22*

You can configure a `variant`, `style`, and `weight` on `layout.font`. Here, we set the font variant to `small-caps`.

```python
import plotly.graph_objects as go
from plotly import data

df = data.iris()

setosa_df = df[df["species"] == "setosa"]
versicolor_df = df[df["species"] == "versicolor"]
virginica_df = df[df["species"] == "virginica"]

fig = go.Figure(
data=[
go.Scatter(
x=setosa_df["sepal_width"],
y=setosa_df["sepal_length"],
mode="markers",
name="setosa",
),
go.Scatter(
x=versicolor_df["sepal_width"],
y=versicolor_df["sepal_length"],
mode="markers",
name="versicolor",
),
go.Scatter(
x=virginica_df["sepal_width"],
y=virginica_df["sepal_length"],
mode="markers",
name="virginica",
),
],
layout=go.Layout(
title="Plot Title",
xaxis=dict(title="X Axis Title"),
yaxis=dict(title="Y Axis Title"),
legend=dict(title="Legend Title"),
font=dict(
family="Courier New, monospace",
size=18,
color="RebeccaPurple",
variant="small-caps",
)
)
)

fig.show()
```

The configuration of the legend is discussed in detail in the [Legends](/python/legend/) page.

### Align Plot Title
Expand Down

0 comments on commit 025eea7

Please sign in to comment.