This documentation is for Dash Enterprise.
Dash Enterprise is the fastest way to write & deploy Dash apps and
Jupyter notebooks.
10% of the Fortune 500 uses Dash Enterprise to productionize AI and
data science apps. Find out if your company is using Dash Enterprise.
Kaleido is a library for exporting static images from Plotly figures. In this chapter, we will go over exporting static images from your Jupyter Notebook with Kaleido.
You can install Kaleido with:
$ pip install --upgrade "plotly[kaleido]"
Plotly figures provide methods for exporting images. Use write_image to export a figure to a file.
import plotly.express as px
data_canada = px.data.gapminder().query("country == 'Canada'")
fig = px.bar(data_canada, x='year', y='pop')
fig.write_image("fig1.png")
Or use to_image to export an image to a bytes object. When using to_image, you need to specify an image format:
import plotly.express as px
data_canada = px.data.gapminder().query("country == 'Canada'")
fig = px.bar(data_canada, x='year', y='pop')
img_bytes = fig.to_image(format="png")
See the Plotly.py static image export documentation for complete documentation.
Kaleido supports converting Plotly figures to PNG, JPG, WebP, SVG, and PDF formats.
Kaleido versions before v1 also supported EPS. To export to EPS, you will need to install the optional
python-popplerlibrary.