【发布时间】:2021-02-24 11:34:58
【问题描述】:
我想可视化将直线拟合到 2D 数据集的过程。 对于每个时期,我都有起点和直线终点的 x 和 y 坐标。下面是带有线条的数据集的示例图像 (matplotlib)。
我看到 plotly 提供了一个动画线条的选项。
上面的情节是用类似这样的代码创建的:
# this should animate my line
fig_data = px.line(df, x="xxx", y="yyy", animation_frame="epoch", animation_group="name", title="fitted line")
# responsible for the red scatter plot points:
fig_data.add_traces(
go.Scatter(
x=xxx,
y=yyy, mode='markers', name='House in Dataset')
)
数据框如下所示:
epoch xxx yyy name
0 0 [0.5, 4] [1.4451884285714285, 4.730202428571428] example
1 1 [0.5, 4] [1.3944818842653062, 4.4811159469795925] example
2 2 [0.5, 4] [1.3475661354539474, 4.251154573663417] example
3 3 [0.5, 4] [1.3041510122346094, 4.03885377143571] example
所以应该在 epoch 0 中显示的行从 (0.5,1.44) 开始到 (4,4.73)。 但是,没有渲染线。我应该改变什么?
【问题讨论】:
-
datapoints_x和datapoint_y来自哪里? -
我的错。现在修好了。
标签: python plotly plotly-dash