Skip to content

Commit dc2453e

Browse files
committed
Update legend.md
1 parent 981ace8 commit dc2453e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

doc/python/legend.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.14.5
9+
jupytext_version: 1.14.6
1010
kernelspec:
1111
display_name: Python 3 (ipykernel)
1212
language: python
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.10.11
23+
version: 3.10.8
2424
plotly:
2525
description: How to configure and style the legend in Plotly with Python.
2626
display_as: file_settings
@@ -580,7 +580,7 @@ fig.show()
580580

581581
By default, all traces appear on one legend. To have multiple legends, specify an alternative legend for a trace using the `legend` property. For a second legend, set `legend="legend2"`. Specify more legends with `legend="legend3"`, `legend="legend4"` and so on.
582582

583-
In this example, the last two scatter traces display on the second legend, "legend2". On the figure's layout, we then position and style this legend to display on the right of the graph below the first legend.
583+
In this example, the last two scatter traces display on the second legend, "legend2". On the figure's layout, we then position and style each legend.
584584

585585

586586
```python
@@ -622,20 +622,25 @@ fig = go.Figure(
622622
],
623623
layout=dict(
624624
title="GDP Per Capita",
625-
legend={"title": "By country", "bgcolor": "Orange",},
625+
legend={
626+
"title": "By country",
627+
"xref": "container",
628+
"yref": "container",
629+
"y": 0.65,
630+
"bgcolor": "Orange",
631+
},
626632
legend2={
627-
"x": 1.155,
628-
"y": 0.55,
629-
"xanchor": "right",
630-
"yanchor": "middle",
633+
"title": "By continent",
634+
"xref": "container",
635+
"yref": "container",
636+
"y": 0.85,
631637
"bgcolor": "Gold",
632-
"title": {"text": "By continent"},
638+
633639
},
634640
),
635641
)
636642

637643
fig.show()
638-
639644
```
640645

641646
### Positioning Legends

0 commit comments

Comments
 (0)