gpt4 book ai didi

python - plotly add_trace 与 append_trace

转载 作者:行者123 更新时间:2023-12-04 13:10:44 25 4
gpt4 key购买 nike

add_trace有什么区别吗和 append_trace在 plotly ?后者是前者的遗产吗?
Plotly.py GitHub , 有 88 个 markdown + 21 个 Python 实例 add_trace和 9 个 markdowbn + 7 个 Python 实例 append_trace .后者主要来自docpackages/python/plotly/plotly/figure_factory .
Plotly subplots documentation , 有 4 个 append_trace 的实例而所有其他 52 个实例是 add_trace .
这是从那里提取的示例:

from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(rows=3, cols=1)

fig.append_trace(go.Scatter(
x=[3, 4, 5],
y=[1000, 1100, 1200],
), row=1, col=1)

fig.append_trace(go.Scatter(
x=[2, 3, 4],
y=[100, 110, 120],
), row=2, col=1)

fig.append_trace(go.Scatter(
x=[0, 1, 2],
y=[10, 11, 12]
), row=3, col=1)


fig.update_layout(height=600, width=600, title_text="Stacked Subplots")
fig.show()
我试过更换 append_trace此代码片段中的实例为 add_trace并没有观察到任何明显的差异。

最佳答案

我没有技术背景给你解释,但是官方reference有以下解释

New traces can be added to a graph object figure using the add_trace() method. This method accepts a graph object trace (an instance of go.Scatter, go.Bar, etc.) and adds it to the figure. This allows you to start with an empty figure, and add traces to it sequentially. The append_trace() method does the same thing, although it does not return the figure.

关于python - plotly add_trace 与 append_trace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65505336/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com