Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Plotly:如何使用Plotly express组合散点图和线图,以便散点图和线图随动画帧的变化而变化?_Python_Plotly_Plotly Python_Plotly Express - Fatal编程技术网

Python Plotly:如何使用Plotly express组合散点图和线图,以便散点图和线图随动画帧的变化而变化?

Python Plotly:如何使用Plotly express组合散点图和线图,以便散点图和线图随动画帧的变化而变化?,python,plotly,plotly-python,plotly-express,Python,Plotly,Plotly Python,Plotly Express,我已经创建了一个动画散点图: 但我需要添加一条直线图(只是一条简单的划分死亡和活着患者数量的直线, 但线条需要更改每个动画(每帧)。 该线的参数将由一个简单的感知器算法导出 fig = px.scatter(data_frame=df, x="neutrophils count", y="(%)lymphocyte", color="ou

我已经创建了一个动画散点图:

但我需要添加一条直线图(只是一条简单的划分死亡和活着患者数量的直线, 但线条需要更改每个动画(每帧)。 该线的参数将由一个简单的感知器算法导出

fig = px.scatter(data_frame=df, 
                 x="neutrophils count", 
                 y="(%)lymphocyte", 
                 color="outcome", 
                 animation_frame="days_from_admission",
                 color_continuous_scale=["green", "red"], 
                 category_orders={"days_from_admission": [x for x in range(0, 22)]},
                 labels={"days_from_admission": "Days from admission", "outcome": "Patient outcome:"},
                 title="Exemplary title")

fig.layout.updatemenus[0].buttons[0].args[1]['frame']['duration'] = 800
fig.layout.updatemenus[0].buttons[0].args[1]['transition']['duration'] = 100

fig.update_layout(title={'x': 0.5, 'xanchor': 'center', 'font': {'size': 20}},
                  xaxis=dict(title=dict(font=dict(size=20))),
                  yaxis=dict(title=dict(font=dict(size=20))),
                  legend={'font': {'size': 18}, 'title': {'font': {'size': 18}}})

#fig.add_vline()
#fig.add_trace()
pio.show(fig)
我知道我可以添加一条V线或轨迹,但我不知道如何使其沿侧面动画帧变化。 (例如,vline在每个动画帧上保持不变,并且不接受参数“animation_frame”)