简体   繁体   English

如何抑制 plotly 中 update_layout 的绘图?

[英]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.

相关问题 单击几下后,“update_layout”无法正常工作 - ‘update_layout’ in plotly not working after a few clicks 如何将 update_layout 边距限制为 Plotly/Dash 中的一个子图? - How to limit update_layout margins only to one subplot in Plotly / Dash? Plotly AttributeError:'Figure'对象没有属性'update_layout' - Plotly AttributeError: 'Figure' object has no attribute 'update_layout' Plotly:如何使用 plotly 作为 pandas 的绘图后端来制作不同的绘图? - Plotly: How to make different plots using plotly as a plotting backend for pandas? 如何从图中删除 plotly 徽标(“Produced with plotly”) - How to remove plotly logo ("Produced with plotly") from plots 使用散点图绘制未排序的数据帧 - Plotting Unsorted Dataframes with Plotly Scatter Plots 如何防止情节自动绘图 - How to prevent plotly from plotting automatically 如何使用plotly python中的下拉按钮更新多个散点图的数据? - How to update data of multiple scatter plots with dropdown buttons in plotly python? 在 Python Dash Graph update_layout 中使用 rangeslider 将数据重新设置为相对性能 - Rebase data to relative performance with rangeslider in Python Dash Graph update_layout 如何抑制output的一系列情节 - How to suppress output of a series of plots
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM