Skip to content

Commit 0a9d5f7

Browse files
download opts
1 parent a022a20 commit 0a9d5f7

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

Diff for: doc/python/configuration-options.md

+23-9
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ fig.add_trace(
163163
fig.show(config=config)
164164
```
165165

166-
##### Customizing Download Plot Options
166+
##### Customizing Download Plot Button Options
167167

168-
```python
169-
import plotly.graph_objects as go
168+
The camera icon on the modebar causes a static version of the figure to be downloaded via the user's browser. The default behaviour is to download a PNG of size 700 by 450 pixels.
170169

171-
fig = go.Figure()
170+
This behavior can be controlled via the `toImageButtonOptions` configuration key.
171+
172+
```python
173+
import plotly.express as px
172174

173175
config = {
174176
'toImageButtonOptions': {
@@ -180,10 +182,22 @@ config = {
180182
}
181183
}
182184

183-
fig.add_trace(
184-
go.Scatter(
185-
x=[1, 2, 3],
186-
y=[1, 3, 1]))
185+
fig = px.bar(x=[1, 2, 3], y=[1, 3, 1]))
186+
187+
fig.show(config=config)
188+
```
189+
190+
Figures can be set to download at the currently-rendered size by setting `height` and `width` to `None`:
191+
192+
193+
```python
194+
import plotly.express as px
195+
196+
config = {
197+
'toImageButtonOptions': { 'height': None, 'width': None, }
198+
}
199+
200+
fig = px.bar(x=[1, 2, 3], y=[1, 3, 1]))
187201

188202
fig.show(config=config)
189203
```
@@ -285,4 +299,4 @@ The same configuration dictionary that you pass to the `config` parameter of the
285299

286300
#### Reference
287301

288-
See config options at https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L6
302+
See config options at https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L6

0 commit comments

Comments
 (0)