图 object update_xaxes 未更新
graph object update_xaxes not updating
我有这个简单的代码:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
surf=make_subplots(
rows=1,
cols=2,
subplot_titles=(
'Surface growing for {} seconds'.format(stop),
'Surface growing for {} seconds'.format(stop)
),
horizontal_spacing=0.1,
specs=[[{"type": "scene"},{"type": "scene"}]]
)
surf.update_layout(
template='plotly_dark',
updatemenus=[
dict(
font=dict(
family='Open Sans',
size=15,
color='black'
),
bgcolor='gray',
bordercolor='white',
borderwidth=3,
type='buttons',
buttons=[
dict(
label='Play',
method='animate',
args=[None]
)
]
)
],
width=1200,
height=900
)
surf.add_trace(
go.Scatter3d(
showlegend=False,mode='markers',x=[0],y=[0],z=[0],marker_size=9
),1,1
)
surf.add_trace(
go.Scatter3d(
showlegend=False,mode='markers',x=[0],y=[0],z=[0],marker_size=9
),1,2
)
surf.update_xaxes(title='X Real',row=1,col=1)
pio.show(surf)
但是 X 轴的标题没有更新,如您在附图中所见:
我在 plotly 社区看到指令:surf.update_xaxes(title='X Real',row=1,col=1)
是解决在 plotly 子图中更新轴属性这个问题的有效解决方案,但对我来说由于某种我无法确定的原因不起作用。谁能帮我告诉我我错过了什么?谢谢。
在这里你应该使用不同的方式来更新布局。我也为第二个子图添加了一个示例。
surf.update_layout(scene=dict(xaxis_title='X Real'),
scene2=dict(xaxis_title='X Fake'))
其中 scene
是第一个子图的布局,而 scene2
是第二个子图的布局。
我有这个简单的代码:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
surf=make_subplots(
rows=1,
cols=2,
subplot_titles=(
'Surface growing for {} seconds'.format(stop),
'Surface growing for {} seconds'.format(stop)
),
horizontal_spacing=0.1,
specs=[[{"type": "scene"},{"type": "scene"}]]
)
surf.update_layout(
template='plotly_dark',
updatemenus=[
dict(
font=dict(
family='Open Sans',
size=15,
color='black'
),
bgcolor='gray',
bordercolor='white',
borderwidth=3,
type='buttons',
buttons=[
dict(
label='Play',
method='animate',
args=[None]
)
]
)
],
width=1200,
height=900
)
surf.add_trace(
go.Scatter3d(
showlegend=False,mode='markers',x=[0],y=[0],z=[0],marker_size=9
),1,1
)
surf.add_trace(
go.Scatter3d(
showlegend=False,mode='markers',x=[0],y=[0],z=[0],marker_size=9
),1,2
)
surf.update_xaxes(title='X Real',row=1,col=1)
pio.show(surf)
但是 X 轴的标题没有更新,如您在附图中所见:
surf.update_xaxes(title='X Real',row=1,col=1)
是解决在 plotly 子图中更新轴属性这个问题的有效解决方案,但对我来说由于某种我无法确定的原因不起作用。谁能帮我告诉我我错过了什么?谢谢。
在这里你应该使用不同的方式来更新布局。我也为第二个子图添加了一个示例。
surf.update_layout(scene=dict(xaxis_title='X Real'),
scene2=dict(xaxis_title='X Fake'))
其中 scene
是第一个子图的布局,而 scene2
是第二个子图的布局。