Summary
I have complex data which needs to be plotted using plotly, zoomed to select a preferred range and afterwards exported to pdf. I can successfully export the colored plot to pdf (see code below). However, the zoomed area is not maintained but the entire data range is exported as pdf.
Is it possible to obtain
Steps to reproduce
import plotly.io as pio
import streamlit as st
import plotly.express as px
df = px.data.tips()
fig = px.scatter(
df,
x="total_bill",
y="tip",
color="day",
color_discrete_sequence=[
"#0068c9",
"#83c9ff",
"#ff2b2b",
"#ffabab",
"#29b09d",
"#7defa1",
"#ff8700",
"#ffd16a",
"#6d3fc0",
"#d5dae5",
],
title="streamlit colors",
)
fig.update_layout({"uirevision": "foo"}, overwrite=True)
st.plotly_chart(fig)
# write file
pdf_bytes = pio.to_image(fig, format='pdf', scale=1.0)
# add a download button for the PDF file
st.download_button(
label='Download PDF',
data=pdf_bytes,
file_name='my_plot.pdf',
mime='application/pdf'
)
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
Export the pdf according to the zoomed data range.
Actual behavior:
The full data range is exported
Debug info
- Streamlit version: 1.20.0
- Python version: 3.10.6
- OS version: Ubuntu Linux 22.04
- Browser version: Firefox and Chrome