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
add code here
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Explain what you expect to happen when you run the code above.
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.
- Streamlit version: (get it with
$ streamlit version)
- Python version: (get it with
$ python --version)
- Using Conda? PipEnv? PyEnv? Pex?
- OS version:
- Browser version:
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:
If needed, add any other context about the problem here.
Can you share a code snippet so we can try to reproduce the issue?
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:
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
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
pyo.plot(fig, filename=‘plot.html’, auto_open=False)
with open(‘plot.html’, ‘r’) as f:
html = f.read()
b64 = base64.b64encode(html.encode()).decode()
href = f’Download plot’
st.button(‘Download plot’, on_click=download_plot)