plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
Other
348 stars 33 forks source link

Save order is always wrong #172

Open zhimin-z opened 5 months ago

zhimin-z commented 5 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 5 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 5 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...