繁体   English   中英

如何更新第二个绘图轴 plotly Scatter3D 子图

[英]How update 2nd plots axis plotly Scatter3D subplots

祝你有美好的一天,

我正在尝试使用 plotlies 的 Scatter3d plot 随着时间的推移复杂系列的虚数和实数部分。 X 是实部,Y 是虚部,z 是时间。

但是我有两个系列,我想并排显示两个生成的散点图以进行比较。 为此,我正在使用 makesubplot function。

现在我想 label 每个轴都有相应的名称(见上文)。 但我只能更新第一个子图,而不是第二个。

这是我的源代码,它只更新第 1 行第 1 列中的第一个子图:

d_E1 = go.Scatter3d(
    x=df['Real_E1'],
    y=df['Im_E1'],
    z=df['Time'],
    )
d_E2 = go.Scatter3d(
    x=df['Real_E2'],
    y=df['Im_E2'],
    z=df['Time'],
    )

fig                 = make_subplots(   
                                    rows    = 1,  
                                    cols    = 2,
                                   specs    = [[{"type": "scene"}, {"type": "scene"}]],                                          
                                    )

fig.update_layout(scene = dict(
                  xaxis = dict( title='X AXIS TITLE'),
                  yaxis = dict( title='y AXIS TITLE'),
                  zaxis = dict( title='Z AXIS TITLE')
                ))
 
fig.add_trace(d_E1, row=1, col=1)
fig.add_trace(d_E2, row=1, col=2)
plotly.offline.plot(fig, filename='3d.html')

上面代码的结果

我尝试如下更改 fig.update_layout ,这当然没有用:

1 这更新了 go.散点图。 我可以运行代码,但它没有任何改变。

fig.update_xaxes(title_text="X AXIS TITLE", row=1, col=1)
fig.update_xaxes(title_text="X AXIS TITLE", row=1, col=2)

2 在 Stackoverflow 上我发现了这个:

fig['layout']['xaxis']['title']='Label x-axis 1'
fig['layout']['xaxis2']['title']='Label x-axis 2'
fig['layout']['yaxis']['title']='Label y-axis 1'
fig['layout']['yaxis2']['title']='Label y-axis 2'

错误是,xaxis2 是 xaxis2 未在此上下文中定义? 错误信息

3 在同一个网站上有一个带有 for 循环的解决方案,我可以运行代码,但它没有任何改变... Plotly:如何将轴布局添加到子图中?

4 然后我尝试了这个,我的编译器说他不知道 xaxis2:

fig.update_layout(scene = dict(
xaxis = dict( title='X AXIS TITLE'),
xaxis2 = dict( title='X AXIS TITLE'),
yaxis = dict( title='y AXIS TITLE'),
zaxis = dict( title='Z AXIS TITLE')))

我正在使用plotly版本 4.14.3

我刚刚找到它:

https://github.com/plotly/plotly.py/issues/2483

fig.update_scenes(
                      xaxis = dict( title_text='x-title'),
                      yaxis = dict( title_text='y-title'),
                      zaxis = dict( title_text='z-title'),
                )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM