Skip to content

Commit ce8f577

Browse files
committed
update title to dict
1 parent 2164784 commit ce8f577

13 files changed

+181
-85
lines changed

doc/python/3d-bubble-charts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ fig = go.Figure(go.Scatter3d(
184184
fig.update_layout(
185185
width=800,
186186
height=800,
187-
title="Planets!",
187+
title=dict(text="Planets!"),
188188
scene=dict(
189189
xaxis=dict(
190190
title=dict(

doc/python/dot-plots.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,21 @@ fig.add_trace(go.Scatter(
9898
name="Men",
9999
))
100100

101-
fig.update_layout(title="Gender Earnings Disparity",
102-
xaxis_title="Annual Salary (in thousands)",
103-
yaxis_title="School")
101+
fig.update_layout(
102+
title=dict(
103+
text="Gender Earnings Disparity"
104+
),
105+
xaxis=dict(
106+
title=dict(
107+
text="Annual Salary (in thousands)"
108+
)
109+
),
110+
yaxis=dict(
111+
title=dict(
112+
text="School"
113+
)
114+
),
115+
)
104116

105117
fig.show()
106118
```
@@ -139,7 +151,7 @@ fig.add_trace(go.Scatter(
139151
fig.update_traces(mode='markers', marker=dict(line_width=1, symbol='circle', size=16))
140152

141153
fig.update_layout(
142-
title="Votes cast for ten lowest voting age population in OECD countries",
154+
title=dict(text="Votes cast for ten lowest voting age population in OECD countries"),
143155
xaxis=dict(
144156
showgrid=False,
145157
showline=True,

doc/python/dumbbell-plots.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ fig = go.Figure(
8989
color="green",
9090
size=10
9191
)
92-
92+
9393
),
9494
go.Scatter(
9595
x=data["2002"],
@@ -99,13 +99,13 @@ fig = go.Figure(
9999
marker=dict(
100100
color="blue",
101101
size=10
102-
)
102+
)
103103
),
104104
]
105105
)
106106

107107
fig.update_layout(
108-
title="Life Expectancy in Europe: 1952 and 2002",
108+
title=dict(text="Life Expectancy in Europe: 1952 and 2002"),
109109
height=1000,
110110
legend_itemclick=False
111111
)
@@ -158,16 +158,16 @@ fig = go.Figure(
158158
mode="markers+lines",
159159
showlegend=False,
160160
marker=dict(
161-
symbol="arrow",
162-
color="black",
163-
size=16,
164-
angleref="previous",
161+
symbol="arrow",
162+
color="black",
163+
size=16,
164+
angleref="previous",
165165
standoff=8
166166
)
167167
),
168168
go.Scatter(
169169
x=data["1952"],
170-
y=countries,
170+
y=countries,
171171
name="1952",
172172
mode="markers",
173173
marker=dict(
@@ -189,7 +189,7 @@ fig = go.Figure(
189189
)
190190

191191
fig.update_layout(
192-
title="Life Expectancy in Europe: 1952 and 2002",
192+
title=dict(text="Life Expectancy in Europe: 1952 and 2002"),
193193
height=1000,
194194
legend_itemclick=False
195195
)

doc/python/figure-labels.md

+37-9
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fig.show()
9090

9191
*New in 5.14*
9292

93-
Set `automargin=True` to allow the title to push the figure margins. With `yref` set to `paper`, `automargin=True` expands the margins to make the title visible, but doesn't push outside the container. With `yref` set to `container`, `automargin=True` expands the margins, but the title doesn't overlap with the plot area, tick labels, and axis titles.
93+
Set `automargin=True` to allow the title to push the figure margins. With `yref` set to `paper`, `automargin=True` expands the margins to make the title visible, but doesn't push outside the container. With `yref` set to `container`, `automargin=True` expands the margins, but the title doesn't overlap with the plot area, tick labels, and axis titles.
9494

9595

9696
```python
@@ -145,10 +145,24 @@ fig.add_trace(go.Scatter(
145145
))
146146

147147
fig.update_layout(
148-
title="Plot Title",
149-
xaxis_title="X Axis Title",
150-
yaxis_title="Y Axis Title",
151-
legend_title="Legend Title",
148+
title=dict(
149+
text="Plot Title"
150+
),
151+
xaxis=dict(
152+
title=dict(
153+
text="X Axis Title"
154+
)
155+
),
156+
yaxis=dict(
157+
title=dict(
158+
text="Y Axis Title"
159+
)
160+
),
161+
legend=dict(
162+
title=dict(
163+
text="Legend Title"
164+
)
165+
),
152166
font=dict(
153167
family="Courier New, monospace",
154168
size=18,
@@ -197,10 +211,24 @@ fig = go.Figure(
197211
),
198212
],
199213
layout=go.Layout(
200-
title="Plot Title",
201-
xaxis=dict(title="X Axis Title"),
202-
yaxis=dict(title="Y Axis Title"),
203-
legend=dict(title="Legend Title"),
214+
title=dict(
215+
text="Plot Title"
216+
),
217+
xaxis=dict(
218+
title=dict(
219+
text="X Axis Title"
220+
)
221+
),
222+
yaxis=dict(
223+
title=dict(
224+
text="Y Axis Title"
225+
)
226+
),
227+
legend=dict(
228+
title=dict(
229+
text="Legend Title"
230+
)
231+
),
204232
font=dict(
205233
family="Courier New, monospace",
206234
size=18,

doc/python/hover-text-and-formatting.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ df = data.stocks()
131131

132132
layout = dict(
133133
hoversubplots="axis",
134-
title="Stock Price Changes",
134+
title=dict(text="Stock Price Changes"),
135135
hovermode="x",
136136
grid=dict(rows=3, columns=1),
137137
)

doc/python/legend.md

+29-22
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ fig.add_trace(go.Scatter(
492492
line=dict(color="MediumPurple")
493493
))
494494

495-
fig.update_layout(title="Try Clicking on the Legend Items!")
495+
fig.update_layout(title=dict(text="Try Clicking on the Legend Items!"))
496496

497497
fig.show()
498498
```
@@ -542,15 +542,15 @@ fig.add_trace(go.Scatter(
542542
showlegend=False
543543
))
544544

545-
fig.update_layout(title="Try Clicking on the Legend Items!")
545+
fig.update_layout(title=dict(text="Try Clicking on the Legend Items!"))
546546
fig.show()
547547
```
548548

549549
#### Indent Legend Entries
550550

551551
*New in 5.20*
552552

553-
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.
553+
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.
554554

555555
```python
556556
import plotly.graph_objects as go
@@ -570,7 +570,9 @@ fig = go.Figure(
570570
],
571571
layout=dict(
572572
legend=dict(
573-
title="Species",
573+
title=dict(
574+
text="Species",
575+
),
574576
indentation=10
575577
)
576578
),
@@ -629,7 +631,7 @@ fig.add_trace(go.Scatter(
629631
line=dict(color="MediumPurple")
630632
))
631633

632-
fig.update_layout(title="Try Clicking on the Legend Items!")
634+
fig.update_layout(title=dict(text="Try Clicking on the Legend Items!"))
633635
fig.update_layout(legend=dict(groupclick="toggleitem"))
634636

635637
fig.show()
@@ -727,22 +729,27 @@ fig = go.Figure(
727729
),
728730
],
729731
layout=dict(
730-
title="GDP Per Capita",
731-
legend={
732-
"title": "By country",
733-
"xref": "container",
734-
"yref": "container",
735-
"y": 0.65,
736-
"bgcolor": "Orange",
737-
},
738-
legend2={
739-
"title": "By continent",
740-
"xref": "container",
741-
"yref": "container",
742-
"y": 0.85,
743-
"bgcolor": "Gold",
744-
745-
},
732+
title=dict(
733+
text="GDP Per Capita"
734+
),
735+
legend=dict(
736+
title=dict(
737+
text="By country"
738+
),
739+
xref="container",
740+
yref="container",
741+
y=0.65,
742+
bgcolor="Orange"
743+
),
744+
legend2=dict(
745+
title=dict(
746+
text="By continent"
747+
),
748+
xref="container",
749+
yref="container",
750+
y=0.85,
751+
bgcolor="Gold"
752+
),
746753
),
747754
)
748755

@@ -770,7 +777,7 @@ fig = go.Figure(
770777
go.Scatter(x=df_uk.year, y=df_uk.gdpPercap, name="UK"),
771778
],
772779
layout=dict(
773-
title="GDP Per Capita",
780+
title=dict(text="GDP Per Capita"),
774781
legend={
775782
"x": 0.9,
776783
"y": 0.9,

doc/python/marker-style.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ fig = go.Figure(go.Scatter(mode="markers", x=namevariants, y=namestems, marker_s
352352
marker_line_color="midnightblue", marker_color="lightskyblue",
353353
marker_line_width=2, marker_size=15,
354354
hovertemplate="name: %{y}%{x}<br>number: %{marker.symbol}<extra></extra>"))
355-
fig.update_layout(title="Mouse over symbols for name & number!",
355+
fig.update_layout(title=dict(text="Mouse over symbols for name & number!"),
356356
xaxis_range=[-1,4], yaxis_range=[len(set(namestems)),-1],
357357
margin=dict(b=0,r=0), xaxis_side="top", height=1400, width=400)
358358
fig.show()
@@ -361,7 +361,7 @@ fig.show()
361361

362362
### Using a Custom Marker
363363

364-
To use a custom marker, set the `symbol` on the `marker`. Here we set it to `diamond`.
364+
To use a custom marker, set the `symbol` on the `marker`. Here we set it to `diamond`.
365365

366366

367367
```python
@@ -390,10 +390,10 @@ fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")
390390

391391
fig.update_traces(
392392
marker=dict(
393-
size=8,
394-
symbol="diamond-open",
393+
size=8,
394+
symbol="diamond-open",
395395
line=dict(
396-
width=2,
396+
width=2,
397397
# color="DarkSlateGrey" Line colors don't apply to open markers
398398
)
399399
),
@@ -465,7 +465,7 @@ fig.show()
465465

466466
*New in 5.11*
467467

468-
When you have multiple markers at one location, you can use `standoff` on a marker to move it away from the other marker in the direction of the `angle`.
468+
When you have multiple markers at one location, you can use `standoff` on a marker to move it away from the other marker in the direction of the `angle`.
469469
In this example, we set `standoff=8` on the `arrow` marker, which is half the size of the other `circle` marker, meaning it points exactly at the `circle`.
470470

471471
```python
@@ -525,7 +525,7 @@ fig = go.Figure(
525525
)
526526

527527
fig.update_layout(
528-
title="Population changes 1987 to 2007",
528+
title=dict(text="Population changes 1987 to 2007"),
529529
width=1000,
530530
height=1000,
531531
showlegend=False,

0 commit comments

Comments
 (0)