MCPcopy Index your code
hub / github.com/plotly/plotly.py / write_image

Method write_image

plotly/basedatatypes.py:3803–3895  ·  view source on GitHub ↗

Convert a figure to a static image and write it to a file or writeable object Parameters ---------- file: str or writeable A string representing a local file path or a writeable object (e.g. a pathlib.Path object or an open file descr

(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

3801 return pio.to_image(self, *args, **kwargs)
3802
3803 def write_image(self, *args, **kwargs):
3804 """
3805 Convert a figure to a static image and write it to a file or writeable
3806 object
3807
3808 Parameters
3809 ----------
3810 file: str or writeable
3811 A string representing a local file path or a writeable object
3812 (e.g. a pathlib.Path object or an open file descriptor)
3813
3814 format: str or None
3815 The desired image format. One of
3816 - 'png'
3817 - 'jpg' or 'jpeg'
3818 - 'webp'
3819 - 'svg'
3820 - 'pdf'
3821 - 'eps' (deprecated) (Requires the poppler library to be installed)
3822
3823 If not specified and `file` is a string then this will default to the
3824 file extension. If not specified and `file` is not a string then this
3825 will default to:
3826 - `plotly.io.defaults.default_format` if engine is "kaleido"
3827 - `plotly.io.orca.config.default_format` if engine is "orca" (deprecated)
3828
3829 width: int or None
3830 The width of the exported image in layout pixels. If the `scale`
3831 property is 1.0, this will also be the width of the exported image
3832 in physical pixels.
3833
3834 If not specified, will default to:
3835 - `plotly.io.defaults.default_width` if engine is "kaleido"
3836 - `plotly.io.orca.config.default_width` if engine is "orca" (deprecated)
3837
3838 height: int or None
3839 The height of the exported image in layout pixels. If the `scale`
3840 property is 1.0, this will also be the height of the exported image
3841 in physical pixels.
3842
3843 If not specified, will default to:
3844 - `plotly.io.defaults.default_height` if engine is "kaleido"
3845 - `plotly.io.orca.config.default_height` if engine is "orca" (deprecated)
3846
3847 scale: int or float or None
3848 The scale factor to use when exporting the figure. A scale factor
3849 larger than 1.0 will increase the image resolution with respect
3850 to the figure's layout pixel dimensions. Whereas as scale factor of
3851 less than 1.0 will decrease the image resolution.
3852
3853 If not specified, will default to:
3854 - `plotly.io.defaults.default_scale` if engine is "kaleido"
3855 - `plotly.io.orca.config.default_scale` if engine is "orca" (deprecated)
3856
3857 validate: bool
3858 True if the figure should be validated before being converted to
3859 an image, False otherwise.
3860

Callers 4

test_bytesioFunction · 0.80
test_fig_write_imageFunction · 0.80

Calls 3

kaleido_availableFunction · 0.90
kaleido_majorFunction · 0.90
getMethod · 0.45

Tested by 4

test_bytesioFunction · 0.64
test_fig_write_imageFunction · 0.64