Skip to content

Commit 600bf7a

Browse files
committed
Update setting-graph-size.md
1 parent 540d9d9 commit 600bf7a

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

doc/python/setting-graph-size.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ jupyter:
55
text_representation:
66
extension: .md
77
format_name: markdown
8-
format_version: '1.2'
9-
jupytext_version: 1.6.0
8+
format_version: '1.3'
9+
jupytext_version: 1.13.7
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.7.6
23+
version: 3.9.0
2424
plotly:
2525
description: How to manipulate the graph size, margins and background color.
2626
display_as: file_settings
@@ -127,6 +127,38 @@ fig.update_yaxes(automargin=True)
127127
fig.show()
128128
```
129129

130+
### Automatically Adjust Specific Margins
131+
You can also set auto-margin for specific sides of the figure. Here, we set `automargin` on the `left` and `top` of the figure.
132+
133+
```python
134+
import plotly.graph_objects as go
135+
136+
137+
fig = go.Figure()
138+
139+
fig.add_trace(go.Bar(
140+
x=["Apples", "Oranges", "Watermelon", "Pears"],
141+
y=[3, 2, 1, 4]
142+
))
143+
144+
fig.update_layout(
145+
autosize=False,
146+
width=500,
147+
height=500,
148+
yaxis=dict(
149+
title_text="Y-axis Title",
150+
ticktext=["Very long label", "long label", "3", "label"],
151+
tickvals=[1, 2, 3, 4],
152+
tickmode="array",
153+
titlefont=dict(size=30),
154+
)
155+
)
156+
157+
fig.update_yaxes(automargin='left+top')
158+
159+
fig.show()
160+
```
161+
130162
#### Reference
131163

132164
See https://plotly.com/python/reference/layout/ for more information and chart attribute options!

0 commit comments

Comments
 (0)