我有一個以這種方式繪制子圖的繪圖:fig = make_subplots( rows=4, cols=1, subplot_titles=("Price, orders and positions", "Margin use", "PnL and fees", "Volume traded"), row_heights=[0.5, 0.2, 0.2, 0.1], vertical_spacing=0.1)# price, orders, etcfig.add_traces( [ # draw price, average price and min / max go.Scatter(name='Price', x=df.index, y=df['price'], mode='lines', line=dict(color='rgba(31, 119, 180, 1.)')), go.Scatter(name='Average Price', x=df.index, y=df['average_price'], mode='lines', line=dict(color='rgba(31, 119, 180, 0.5)')), go.Scatter(x=df.index, y=df['price_max'], mode='lines', marker=dict(color="#444"), line=dict(width=0), showlegend=False), go.Scatter(x=df.index, y=df['price_min'], marker=dict(color="#444"), line=dict(width=0), mode='lines', fillcolor='rgba(68, 68, 68, 0.3)', fill='tonexty', showlegend=False), # draw the long / short orders go.Scatter(name='Long Open Price', x=df.index, y=df['orderlo_price'], mode='lines', line=dict(color='rgb(180, 119, 31)')), go.Scatter(name='Long Close Price', x=df.index, y=df['orderlc_price'], mode='lines', line=dict(width=2, color='rgb(220, 159, 31)')), go.Scatter(name='Short Open Price', x=df.index, y=df['orderso_price'], mode='lines', line=dict(color='rgb(119, 180, 31)')), go.Scatter(name='Short Close Price', x=df.index, y=df['ordersc_price'], mode='lines', line=dict(width=2, color='rgb(159, 220, 31)')), # add the position go.Scatter(name='position', x=df.index, y=df['position_price'], mode='lines', line=dict(color='rgb(240, 200, 40)')) ], rows=[1, 1, 1, 1, 1, 1, 1, 1, 1], cols=[1, 1, 1, 1, 1, 1, 1, 1, 1])如何確保所有子圖在 X 軸縮放和平移方面都是同步的?現在,您可以放大一個子圖,突然間該子圖中的圖形與其他子圖沒有關系。
1 回答

牛魔王的故事
TA貢獻1830條經驗 獲得超3個贊
查看Plotly 文檔的共享 X 軸部分。我相信這就是您正在尋找的。
本質上,添加shared_xaxes=True
到函數中make_subplots()
。
添加回答
舉報
0/150
提交
取消