Skip to content

Commit 2e0b441

Browse files
committed
Add default settings info
1 parent 7c76ee3 commit 2e0b441

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

doc/python/static-image-export.md

+48
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,51 @@ fig = dict({
211211
pio.write_image(fig, "fig.png")
212212
~~~
213213
<!-- #endregion -->
214+
215+
## Image Export Settings
216+
217+
As well as configuring height, width, and other settings by passing arguments when calling `write_image` and `to_image`, you can specify defaults to be used.
218+
219+
### Available Settings
220+
221+
The following settings are availble.
222+
223+
`default_width`: The default pixel width to use on image export.
224+
225+
`default_height`: The default pixel height to use on image export.
226+
227+
`default_scale`: The default image scale factor applied on image export.
228+
229+
`default_format`: The default image format used on export. One of "png", "jpeg", "webp", "svg", "pdf", or "eps" (Kaleido v1 only).
230+
231+
`mathjax`: Location of the MathJax bundle needed to render LaTeX characters. Defaults to a CDN location. If fully offline export is required, set this to a local MathJax bundle.
232+
233+
`topojson`: Location of the topojson files needed to render choropleth traces. Defaults to a CDN location. If fully offline export is required, set this to a local directory containing the Plotly.js topojson files.
234+
235+
`mapbox_access_token`: The default Mapbox access token.
236+
237+
### Configuring Defaults
238+
239+
Since Plotly.py 6.1, settings are available on `plotly.io.defaults`
240+
241+
To set the `default_format` to "jpeg":
242+
243+
~~~python
244+
import plotly.io as pio
245+
pio.defaults.default_format = "jpeg"
246+
~~~
247+
248+
You can also access current defaults. To see the default value for height:
249+
250+
~~~python
251+
import plotly.io as pio
252+
pio.defaults.default_height
253+
~~~
254+
255+
In earlier versions of Plotly.py, these settings are available on `plotly.io.kaleido.scope`. This is deprecated since version 6.1. Use `plotly.io.defaults` instead.
256+
257+
~~~python
258+
import plotly.io as pio
259+
pio.kaleido.scope.default_format = "jpeg"
260+
~~~
261+

0 commit comments

Comments
 (0)