[英]Not able to save plotly plots using to_image or write_image
fig.write_image("images/fig1.png",format='png',engine='kaleido')
This makes my VSCode go bananas, the terminal hangs and the program stops then and there.这让我的 VSCode go 崩溃,终端挂起,程序停止。 Everything works fine if I remove just that line.如果我只删除那条线,一切正常。
I want to save the plots as pngs, but it is not working.我想将绘图保存为 png,但它不起作用。 I have kaleido installed.我安装了万花筒。
Try this version of kaleido.试试这个版本的万花筒。
pip install kaleido==0.1.0post1
It works for me这个对我有用
Complete MWE.完成 MWE。 png gets created as expected. png按预期创建。
import plotly.graph_objects as go
import numpy as np
from pathlib import Path
f = Path.cwd().joinpath("images")
if not f.is_dir(): f.mkdir()
f = f.joinpath("fig1.png")
fig = go.Figure(go.Scatter(x=np.linspace(1,10,100), y=np.sin(np.linspace(-np.pi,np.pi, 100))))
fig.write_image(f,format='png',engine='kaleido')
versions版本
import plotly
import kaleido
print(plotly.__version__, kaleido.__version__)
5.5.0 0.2.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.