Skip to content

Commit 9670c4a

Browse files
committed
Update figure-labels.md
1 parent 6722474 commit 9670c4a

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

doc/python/figure-labels.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ jupyter:
66
extension: .md
77
format_name: markdown
88
format_version: '1.3'
9-
jupytext_version: 1.14.1
9+
jupytext_version: 1.14.5
1010
kernelspec:
11-
display_name: Python 3
11+
display_name: Python 3 (ipykernel)
1212
language: python
1313
name: python3
1414
language_info:
@@ -20,7 +20,7 @@ jupyter:
2020
name: python
2121
nbconvert_exporter: python
2222
pygments_lexer: ipython3
23-
version: 3.8.8
23+
version: 3.10.9
2424
plotly:
2525
description: How to set the global font, title, legend-entries, and axis-titles
2626
in python.
@@ -86,6 +86,26 @@ fig.update_xaxes(title_font_family="Arial")
8686
fig.show()
8787
```
8888

89+
### Set Automargin on the Plot Title
90+
91+
*New in 5.14*
92+
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.
94+
95+
96+
```python
97+
import plotly.express as px
98+
99+
df = px.data.gapminder().query("continent == 'Oceania'")
100+
fig = px.line(df, x="year", y="gdpPercap", color="country")
101+
102+
fig.update_layout(
103+
title=dict(text="Population Growth", font=dict(size=50), automargin=True, yref='paper')
104+
)
105+
106+
fig.show()
107+
```
108+
89109
### Fonts and Labels in Dash
90110

91111
[Dash](https://plotly.com/dash/) is the best way to build analytical apps in Python using Plotly figures. To run the app below, run `pip install dash dash-daq`, click "Download" to get the code and run `python app.py`.

0 commit comments

Comments
 (0)