Skip to content

Commit ec09285

Browse files
authored
added example with legend title (#2048)
1 parent 13a1c2e commit ec09285

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

doc/python/legend.md

+26-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.1'
9-
jupytext_version: 1.1.6
8+
format_version: '1.2'
9+
jupytext_version: 1.3.0
1010
kernelspec:
1111
display_name: Python 3
1212
language: python
@@ -138,6 +138,29 @@ fig.add_trace(go.Scatter(
138138
fig.show()
139139
```
140140

141+
#### Legend titles
142+
143+
```python
144+
import plotly.graph_objects as go
145+
146+
fig = go.Figure()
147+
148+
fig.add_trace(go.Scatter(
149+
x=[1, 2, 3, 4, 5],
150+
y=[1, 2, 3, 4, 5],
151+
name="Increasing"
152+
))
153+
154+
fig.add_trace(go.Scatter(
155+
x=[1, 2, 3, 4, 5],
156+
y=[5, 4, 3, 2, 1],
157+
name="Decreasing"
158+
))
159+
160+
fig.update_layout(legend_title='<b> Trend </b>')
161+
fig.show()
162+
```
163+
141164
#### Horizontal Legend
142165

143166
```python
@@ -200,7 +223,7 @@ fig.add_trace(go.Scatter(
200223
))
201224

202225
fig.update_layout(
203-
legend=go.layout.Legend(
226+
legend=dict(
204227
x=0,
205228
y=1,
206229
traceorder="normal",

0 commit comments

Comments
 (0)