[英]How to suppress plotting of plots from update_layout in plotly?
I'm plotting using plotly and plotly express a line graph, which is updated using fig.update_figure.我正在使用 plotly 和 plotly 绘制线图,使用 fig.update_figure 进行更新。 However every updated parameter in update_figure results in the plot being plotted as a graphical output, so I end up having four intermediate plots and final one.
然而,update_figure 中的每个更新参数都会导致 plot 被绘制为图形 output,所以我最终得到了四个中间图和最后一个。 How can I suppress outputs from fig.update_figue?
如何抑制 fig.update_figue 的输出? I thought the overwrite parameter would help but obviously not.
我认为覆盖参数会有所帮助,但显然不是。 Here's how the outputs look like
这是输出的样子
Here is the actual code:这是实际的代码:
fig_Fahmy = plotly.express.line(
data_melt3,
x="Heat data",
y="Flow data",
color="variable",
height=800,
width=1300,
title="Fahmy plot of heat flow ~ cumulative heat",
labels={
"Flow data": "Heat flow, W",
"Heat data": "Cumulative heat, J",
"variable": ""
}
)
fig_Fahmy.update_traces(line=dict(width=2))
fig_Fahmy.update_xaxes(
linewidth=1,
linecolor='black',
mirror=True,
ticks='inside',
showline=True,
gridcolor="white",
zerolinecolor="darkgray",
title_font=dict(size=20),
tickfont=dict(size=15),
ticklen=10,
tickwidth=2
)
fig_Fahmy.update_yaxes(
linewidth=1,
linecolor='black',
mirror=True,
ticks='inside',
showline=True,
gridcolor="white",
zerolinecolor="darkgray",
title_font=dict(size=20),
tickfont=dict(size=15),
ticklen=10,
tickwidth=2
)
fig_Fahmy.update_layout(
overwrite=True,
plot_bgcolor="rgba(0, 0, 0, 0)",
legend=dict(itemsizing='constant'),
legend_font=dict(size=15),
title_font=dict(size=25)
)
fig_Fahmy.show() if outputs == True else None
It's probably something obvious but I'm kinda new in this.这可能是显而易见的,但我在这方面有点新。 Thanks for any hints!
感谢您的任何提示!
Welcome to Stackoverflow and thank you for asking a good question.欢迎来到 Stackoverflow,感谢您提出一个好问题。 Next time please add a small dummy data set so your example problem can be replicated out of the box.
下次请添加一个小的虚拟数据集,以便可以立即复制您的示例问题。
To supress multiple outputs just overwrite your figure variable and keep the fig_Fahmy.show()
statement at the end of your script.要抑制多个输出,只需覆盖您的图形变量并将
fig_Fahmy.show()
语句保留在脚本末尾。
For example your first update line:例如您的第一个更新行:
fig_Fahmy = fig_Fahmy.update_traces(line=dict(width=2))
Hope this solves your issue.希望这可以解决您的问题。 If so please accept my answer by clicking at the arrow tick.
如果是这样,请通过单击箭头来接受我的回答。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.