6
6
extension : .md
7
7
format_name : markdown
8
8
format_version : ' 1.3'
9
- jupytext_version : 1.16.1
9
+ jupytext_version : 1.16.2
10
10
kernelspec :
11
11
display_name : Python 3 (ipykernel)
12
12
language : python
@@ -20,7 +20,7 @@ jupyter:
20
20
name : python
21
21
nbconvert_exporter : python
22
22
pygments_lexer : ipython3
23
- version : 3.10.11
23
+ version : 3.10.0
24
24
plotly :
25
25
description : How to add text labels and annotations to plots in python.
26
26
display_as : file_settings
@@ -395,6 +395,57 @@ fig.show()
395
395
396
396
```
397
397
398
+ ## Numeric Font Weight
399
+
400
+ * New in 5.23*
401
+
402
+ In the previous example, we set a ` font-weight ` using a keyword value. You can also set ` font-weight ` using a numeric value.
403
+
404
+ The font weights available depend on the ` font-family ` that is set. The ` font-weight `
405
+ If you set a ` font-weight ` that isn't available for a particular ` font-family ` , the weight will be rounded to the nearest available value.
406
+
407
+ In the following example,
408
+
409
+
410
+ ``` python
411
+ import plotly.graph_objects as go
412
+ from plotly import data
413
+
414
+ df = data.medals_wide()
415
+
416
+ fig = go.Figure(
417
+ data = [
418
+ go.Bar(
419
+ x = df.nation,
420
+ y = df.gold,
421
+ name = " Gold" ,
422
+ marker = dict (color = " Gold" ),
423
+ text = " Gold" ,
424
+ textfont = dict (weight = 400 , size = 17 ),
425
+ ),
426
+ go.Bar(
427
+ x = df.nation,
428
+ y = df.silver,
429
+ name = " Silver" ,
430
+ marker = dict (color = " MediumTurquoise" ),
431
+ text = " Silver" ,
432
+ textfont = dict (weight = 600 , size = 17 ),
433
+ ),
434
+ go.Bar(
435
+ x = df.nation,
436
+ y = df.bronze,
437
+ name = " Bronze" ,
438
+ marker = dict (color = " LightGreen" ),
439
+ text = " Bronze" ,
440
+ textfont = dict (weight = 1000 , size = 17 ),
441
+ ),
442
+ ],
443
+ layout = dict (barcornerradius = 15 , showlegend = False ),
444
+ )
445
+
446
+ fig.show()
447
+ ```
448
+
398
449
### Styling and Coloring Annotations
399
450
400
451
``` python
0 commit comments