Skip to content

Commit

Permalink
add legend indentation example
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamConnors committed Mar 11, 2024
1 parent e336af4 commit 131fe09
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions doc/python/legend.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.7
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.4
version: 3.10.11
plotly:
description: How to configure and style the legend in Plotly with Python.
display_as: file_settings
Expand Down Expand Up @@ -546,6 +546,45 @@ fig.update_layout(title="Try Clicking on the Legend Items!")
fig.show()
```

```python
df = data.iris()
df
```

#### Indent Legend Entries

*New in 5.20*

To indent legend entries, set `indenation` on `layout.legend` to a number of pixels. In the following example, we indent legend entries by 10 pixels.

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

df = data.iris()

fig = go.Figure(
[
go.Scatter(
x=df[df["species"] == species]["sepal_width"],
y=df[df["species"] == species]["sepal_length"],
mode="markers",
name=species,
)
for species in df["species"].unique()
],
layout=dict(
legend=dict(
title="Species",
indentation=10
)
),
)


fig.show()
```

#### Group click toggle behavior

*New in v5.3*
Expand Down

0 comments on commit 131fe09

Please sign in to comment.