如何使用共享的xaxis在Plotly中进行子图绘制?

时间:2020-08-06 09:17:35

标签: python plotly

我想作图,并执行以下代码:

fig = go.Figure()
fig = make_subplots(rows=2,cols=1,shared_xaxes=True,vertical_spacing=0.5)
fig.add_trace(go.Scatter(x=data['time'],y=data['x_recorded'],mode='lines+markers',name='First'))
fig.add_trace(go.Scatter(x=data['time'],y=data['y_recorded'],mode='lines',name='Second'))
fig.add_trace(go.Scatter(x=data['time'],y=data['x2_recorded'],mode='lines+markers',name='First2'))
fig.add_trace(go.Scatter(x=data['time'],y=data['y2_recorded'],mode='lines',name='Second2'))
fig.update_layout(height=800,width=600,title='Shared_x_axis',)
p_5 = opy.plot(fig,auto_open=False,output_type='div')

根据文档,还有两个附加参数“ row”和“ col”,但是当我将它们放入go.Scatter时,有一个TypeError saying that these arguments cannot be placed。而且,执行完这段代码后,即使定义了xaxis,我也不会得到单独的子图,也不会得到xaxis。 无法找到解决方法。

0 个答案:

没有答案