8000 Update docs examples to use `title.text` instead of title as a string for `title` by LiamConnors · Pull Request #4850 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content

Update docs examples to use title.text instead of title as a string for title #4850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update title to dict
  • Loading branch information
LiamConnors committed Nov 6, 2024
commit ce8f577f79585c79f9b2a68a69d933d484f7e947
2 changes: 1 addition & 1 deletion doc/python/3d-bubble-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ fig = go.Figure(go.Scatter3d(
fig.update_layout(
width=800,
height=800,
title="Planets!",
title=dict(text="Planets!"),
scene=dict(
xaxis=dict(
title=dict(
Expand Down
20 changes: 16 additions & 4 deletions doc/python/dot-plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,21 @@ fig.add_trace(go.Scatter(
name="Men",
))

fig.update_layout(title="Gender Earnings Disparity",
xaxis_title="Annual Salary (in thousands)",
yaxis_title="School")
fig.update_layout(
title=dict(
text="Gender Earnings Disparity"
),
xaxis=dict(
title=dict(
text="Annual Salary (in thousands)"
)
),
yaxis=dict(
title=dict(
text="School"
)
),
)

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

fig.update_layout(
title="Votes cast for ten lowest voting age population in OECD countries",
title=dict(text="Votes cast for ten lowest voting age population in OECD countries"),
xaxis=dict(
showgrid=False,
showline=True,
Expand Down
18 changes: 9 additions & 9 deletions doc/python/dumbbell-plots.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fig = go.Figure(
color="green",
size=10
)

),
go.Scatter(
x=data["2002"],
Expand All @@ -99,13 +99,13 @@ fig = go.Figure(
marker=dict(
color="blue",
size=10
)
)
),
]
)

fig.update_layout(
title="Life Expectancy in Europe: 1952 and 2002",
title=dict(text="Life Expectancy in Europe: 1952 and 2002"),
height=1000,
legend_itemclick=False
)
Expand Down Expand Up @@ -158,16 +158,16 @@ fig = go.Figure(
mode="markers+lines",
showlegend=False,
marker=dict(
symbol="arrow",
color="black",
size=16,
angleref="previous",
symbol="arrow",
color="black",
size=16,
angleref="previous",
standoff=8
)
),
go.Scatter(
x=data["1952"],
y=countries,
y=countries,
name="1952",
mode="markers",
marker=dict(
Expand All @@ -189,7 +189,7 @@ fig = go.Figure(
)

fig.update_layout(
title="Life Expectancy in Europe: 1952 and 2002",
title=dict(text="Life Expectancy in Europe: 1952 and 2002"),
height=1000,
legend_itemclick=False
)
Expand Down
46 changes: 37 additions & 9 deletions doc/python/figure-labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fig.show()

*New in 5.14*

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.
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.


```python
Expand Down Expand Up @@ -145,10 +145,24 @@ fig.add_trace(go.Scatter(
))

fig.update_layout(
title="Plot Title",
xaxis_title="X Axis Title",
yaxis_title="Y Axis Title",
legend_title="Legend Title",
title=dict(
text="Plot Title"
),
xaxis=dict(
title=dict(
text="X Axis Title"
)
),
yaxis=dict(
title=dict(
text="Y Axis Title"
)
),
legend=dict(
title=dict(
text="Legend Title"
)
),
font=dict(
family="Courier New, monospace",
size=18,
Expand Down Expand Up @@ -197,10 +211,24 @@ fig = go.Figure(
),
],
layout=go.Layout(
title="Plot Title",
xaxis=dict(title="X Axis Title"),
yaxis=dict(title="Y Axis Title"),
legend=dict(title="Legend Title"),
title=dict(
text="Plot Title"
),
xaxis=dict(
title=dict(
text="X Axis Title"
)
),
yaxis=dict(
title=dict(
text="Y Axis Title"
)
),
legend=dict(
title=dict(
text="Legend Title"
)
),
font=dict(
family="Courier New, monospace",
size=18,
Expand Down
2 changes: 1 addition & 1 deletion doc/python/hover-text-and-formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ df = data.stocks()

layout = dict(
hoversubplots="axis",
title="Stock Price Changes",
title=dict(text="Stock Price Changes"),
hovermode="x",
grid=dict(rows=3, columns=1),
)
Expand Down
51 changes: 29 additions & 22 deletions doc/python/legend.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ fig.add_trace(go.Scatter(
line=dict(color="MediumPurple")
))

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

fig.show()
```
Expand Down Expand Up @@ -542,15 +542,15 @@ fig.add_trace(go.Scatter(
showlegend=False
))

fig.update_layout(title="Try Clicking on the Legend Items!")
fig.update_layout(title=dict(text="Try Clicking on the Legend Items!"))
fig.show()
```

#### 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.
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
Expand All @@ -570,7 +570,9 @@ fig = go.Figure(
],
layout=dict(
legend=dict(
title="Species",
title=dict(
text="Species",
),
indentation=10
)
),
Expand Down Expand Up @@ -629,7 +631,7 @@ fig.add_trace(go.Scatter(
line=dict(color="MediumPurple")
))

fig.update_layout(title="Try Clicking on the Legend Items!")
fig.update_layout(title=dict(text="Try Clicking on the Legend Items!"))
fig.update_layout(legend=dict(groupclick="toggleitem"))

fig.show()
Expand Down Expand Up @@ -727,22 +729,27 @@ fig = go.Figure(
),
],
layout=dict(
title="GDP Per Capita",
legend={
"title": "By country",
"xref": "container",
"yref": "container",
"y": 0.65,
"bgcolor": "Orange",
},
legend2={
"title": "By continent",
"xref": "container",
"yref": "container",
"y": 0.85,
"bgcolor": "Gold",

},
title=dict(
text="GDP Per Capita"
),
legend=dict(
title=dict(
text="By country"
),
xref="container",
yref="container",
y=0.65,
bgcolor="Orange"
),
legend2=dict(
title=dict(
text="By continent"
),
xref="container",
yref="container",
y=0.85,
bgcolor="Gold"
),
),
)

Expand Down Expand Up @@ -770,7 +777,7 @@ fig = go.Figure(
go.Scatter(x=df_uk.year, y=df_uk.gdpPercap, name="UK"),
],
layout=dict(
title="GDP Per Capita",
title=dict(text="GDP Per Capita"),
legend={
"x": 0.9,
"y": 0.9,
Expand Down
14 changes: 7 additions & 7 deletions doc/python/marker-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ fig = go.Figure(go.Scatter(mode="markers", x=namevariants, y=namestems, marker_s
marker_line_color="midnightblue", marker_color="lightskyblue",
marker_line_width=2, marker_size=15,
hovertemplate="name: %{y}%{x}<br>number: %{marker.symbol}<extra></extra>"))
fig.update_layout(title="Mouse over symbols for name & number!",
fig.update_layout(title=dict(text="Mouse over symbols for name & number!"),
xaxis_range=[-1,4], yaxis_range=[len(set(namestems)),-1],
margin=dict(b=0,r=0), xaxis_side="top", height=1400, width=400)
fig.show()
Expand All @@ -361,7 +361,7 @@ fig.show()

### Using a Custom Marker

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


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

fig.update_traces(
marker=dict(
size=8,
symbol="diamond-open",
size=8,
symbol="diamond-open",
line=dict(
width=2,
width=2,
# color="DarkSlateGrey" Line colors don't apply to open markers
)
),
Expand Down Expand Up @@ -465,7 +465,7 @@ fig.show()

*New in 5.11*

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`.
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`.
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`.

```python
Expand Down Expand Up @@ -525,7 +525,7 @@ fig = go.Figure(
)

fig.update_layout(
title="Population changes 1987 to 2007",
title=dict(text="Population changes 1987 to 2007"),
width=1000,
height=1000,
showlegend=False,
Expand Down
Loading
0