Exporting a Static Image
Exporting a static image from a Plotly Express visualization allows you to save your plots as high-quality files for use in presentations, reports, or publications. Plotly supports exporting images in various formats such as PNG, JPEG, SVG, and PDF. To do this, you need to install the kaleido
library, which serves as a fast and efficient image export engine. After creating a Plotly figure, use the .write_image()
method to save it to a specified file path. For example, after creating a chart (fig
), you can save it as fig.write_image("plot.png")
. You can also adjust the resolution and size by specifying parameters like width
, height
, and scale
. This functionality ensures that your interactive Plotly visualizations can be seamlessly incorporated into static documents or shared in non-interactive formats. Here’s an example:
Ensure you have kaleido
installed (pip install -U kaleido
) before using the export functionality.
Last updated