win10系统在plotly导出图片时程序卡死

在用plotly的write_image时,程序就像进入无限循环一样卡死了。下面是解决方案

pip install --upgrade "kaleido==0.1.*"

这样就能正常输出图片了

import plotly.express as px

df = px.data.iris()
'''注意这里的括号'''
fig=(px.scatter(
    df,
    x="sepal_width",
    y="sepal_length",
    color="species",
    facet_col="species",
    trendline="ols",
    title="Chaining Multiple Figure Operations With A Plotly Express Figure")
 .update_layout(title_font_size=24)
 .update_xaxes(showgrid=False)
 .update_traces(
     line=dict(dash="dot", width=4),
     selector=dict(type="scatter", mode="lines")))
fig.show()

fig.write_image('junpei.png',scale=3
                ,height=800,width=1200)

你可能感兴趣的:(plotly)