Skip to content

Commit 2cec00e

Browse files
committed
Update legend.md
1 parent 00c18fd commit 2cec00e

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

doc/python/legend.md

+27-2
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.13.7
9+
jupytext_version: 1.14.1
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.9.0
23+
version: 3.8.0
2424
plotly:
2525
description: How to configure and style the legend in Plotly with Python.
2626
display_as: file_settings
@@ -185,6 +185,31 @@ fig.update_layout(legend=dict(
185185
fig.show()
186186
```
187187

188+
#### Horizontal Legend Entry Width
189+
190+
*New in 5.11*
191+
192+
Set the width of hozitonal legend entries by setting `entrywidth`. Here we set it to `70` pixels. Pixels is the default unit for `entrywidth`, but you can set it to be a fraction of the plot width with `entrywidthmode='fraction`.
193+
194+
```python
195+
import plotly.express as px
196+
197+
df = px.data.gapminder().query("year==2007")
198+
fig = px.scatter(df, x="gdpPercap", y="lifeExp", color="continent",
199+
size="pop", size_max=45, log_x=True)
200+
201+
fig.update_layout(legend=dict(
202+
orientation="h",
203+
entrywidth=70,
204+
yanchor="bottom",
205+
y=1.02,
206+
xanchor="right",
207+
x=1
208+
))
209+
210+
fig.show()
211+
```
212+
188213
#### Styling Legends
189214

190215
Legends support many styling options.

0 commit comments

Comments
 (0)