All Plots generated via Plotly turns black when Downloaded in HTML/PDF format via the Streamlit application both locally and on the Web


I am trying to download the plotly plots(with animation frame) in html format . File is getting downloaded but the plots are all black. This was working absolutely fine till Streamlit version 1.13.0

Steps to reproduce

Code snippet:

add code here

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

Explain what you expect to happen when you run the code above.

Actual behavior:

Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.

Debug info

  • Streamlit version: (get it with $ streamlit version)
  • Python version: (get it with $ python --version)
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version:
  • Browser version:

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.


  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

Hey @Tinu_Koshy,

Can you share a code snippet so we can try to reproduce the issue?

Hi @Tinu_Koshy :wave:

This seems to be expected behavior and is a duplicate of Black and white colors are only seen when Plotly is downloaded as html file or a png or jpeg file

The solution is described here:

1 Like

The code is shown below and the download plots in the HTML with Streamlit version 1.13.0 is perfect where as the plot with Streamlit version 1.19.0 is black. Attached are the plots

import plotly.graph_objs as go
import plotly.offline as pyo
import streamlit as st
import base64

Create a bar plot using Plotly

data = [go.Bar(x=[‘A’, ‘B’, ‘C’], y=[3, 5, 7])]
layout = go.Layout(title=‘Simple Bar Plot’)
fig = go.Figure(data=data, layout=layout)

Display the plot in Streamlit


Add a button to download the plot in HTML format

def download_plot():
pyo.plot(fig, filename=‘plot.html’, auto_open=False)
with open(‘plot.html’, ‘r’) as f:
html =
b64 = base64.b64encode(html.encode()).decode()
href = f’Download plot
st.markdown(href, unsafe_allow_html=True)

st.button(‘Download plot’, on_click=download_plot)