plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
MIT License
378 stars 38 forks source link

Save order is always wrong #172

Open zhimin-z opened 10 months ago

zhimin-z commented 10 months ago

I am using Plotly and my Python environment is as follows:

python==3.11.6
plotly==5.18.0
kaleido==0.2.1

When I write the following code and execute:

import plotly.express as px

# Create multiple figure objects
fig1 = px.scatter(x=[1, 2, 3], y=[4, 5, 6], title="Figure 1")
fig2 = px.bar(x=[1, 2, 3], y=[7, 8, 9], title="Figure 2")
fig3 = px.line(x=[1, 2, 3], y=[10, 11, 12], title="Figure 3")

# Specify the order in which you want to save the figures
figures_to_save = [fig1, fig2, fig3]

# Loop through the figures and save them in the desired order
for i, fig in enumerate(figures_to_save):
    fig.write_image(f"figure_{i+1}.png")

The generated figure is misordered as follows: figure_1.png image figure_2.png image figure_3.png image

I wonder why this happens and how I can fix it?

ChrisJaunes commented 10 months ago

What is your kaleido version?

python3.10
plotly=5.18.0
kaleido=0.2.1

The save order is normal

zhimin-z commented 10 months ago

What is your kaleido version?

python3.10
plotly=5.18.0
kaleido=0.2.1

The save order is normal

Same as yours except for the python version. This is pretty weird since the wrong order is flaky now. I cannot reproduce it anymore...

gvwilson commented 4 months ago

Thanks for your interest in Kaleido. We are currently working on an overhaul that might address your issue - we hope to have news in a few weeks and will post an update then. Thanks - @gvwilson