Skip to content

Commit f60b7f0

Browse files
committed
add textfont style, variant and weight
1 parent cd5fc87 commit f60b7f0

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

Diff for: doc/python/text-and-annotations.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ fig.update_layout(
307307
fig.show()
308308
```
309309

310-
### Custom Text Color and Styling
310+
### Font Color, Size, and Familiy
311+
312+
Use `textfont` to specify a font `family`, `size`, or `color`.
311313

312314
```python
313315
import plotly.graph_objects as go
@@ -347,6 +349,52 @@ fig.update_layout(showlegend=False)
347349
fig.show()
348350
```
349351

352+
### Font Style, Variant, and Weight
353+
354+
*New in 5.22*
355+
356+
You can also configure a font's `variant`, `style`, and `weight` on `textfont`. Here, we configure an `italic` style on the first bar, `bold` weight on the second, and`small-caps` as the font variant on the third.
357+
358+
```python
359+
import plotly.graph_objects as go
360+
from plotly import data
361+
362+
df = data.medals_wide()
363+
364+
fig = go.Figure(
365+
data=[
366+
go.Bar(
367+
x=df.nation,
368+
y=df.gold,
369+
name="Gold",
370+
marker=dict(color="Gold"),
371+
text="Gold",
372+
textfont=dict(style="italic"),
373+
),
374+
go.Bar(
375+
x=df.nation,
376+
y=df.silver,
377+
name="Silver",
378+
marker=dict(color="MediumTurquoise"),
379+
text="Silver",
380+
textfont=dict(weight="bold"),
381+
),
382+
go.Bar(
383+
x=df.nation,
384+
y=df.bronze,
385+
name="Bronze",
386+
marker=dict(color="LightGreen"),
387+
text="Bronze",
388+
textfont=dict(variant="small-caps"),
389+
),
390+
],
391+
layout=dict(barcornerradius=15, showlegend=False),
392+
)
393+
394+
fig.show()
395+
396+
```
397+
350398
### Styling and Coloring Annotations
351399

352400
```python

0 commit comments

Comments
 (0)