我在 Jupyter Notebook 中本地创建了绘图图表,我试图将其另存为 png 文件在本地计算机上。图表示例:
for table in EG_SD_pivots:
df = EG_SD_pivots[table].reset_index()
fig = make_subplots(specs=[[{"secondary_y": True}]])
fig.add_trace(
go.Scatter(x=df.iloc[:, 0], y=df['SD_Credibility'], name="Credibility", marker=dict(color=yellow)), secondary_y=True)
fig.add_trace(
go.Bar(x=df.iloc[:, 0], y=df['EG_LR_Rel'], name="EG Relativity", marker=dict(color=teal)), secondary_y=False)
fig.add_trace(
go.Bar(x=df.iloc[: ,0], y=df['SD_LR_Rel'], name="SD Relativity", marker=dict(color=indigo)), secondary_y=False)
# Add figure title
fig.update_layout(title_text=df.iloc[:0].columns[0], margin=dict(b=200))
# Set x-axis title
fig.update_xaxes(title_text=df.iloc[:0].columns[0])
fig.update_yaxes(title_text="<b>Relativity</b>", secondary_y=False)
fig.update_yaxes(title_text="<b>Credibility</b>", secondary_y=True)
fig.show()
Run Code Online (Sandbox Code Playgroud)
我尝试了许多不同的解决方案,但它们都返回了各种错误...解决方案:
fig.to_image(format="png")-->返回
ValueError:
The orca executable is required to export figures as static images,
but it could not be found on the system …Run Code Online (Sandbox Code Playgroud)