亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何讓所有子圖在 X 軸上以相同的方式縮放和平移,并使用plotly

如何讓所有子圖在 X 軸上以相同的方式縮放和平移,并使用plotly

心有法竹 2023-12-09 15:43:40
我有一個以這種方式繪制子圖的繪圖: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()


查看完整回答
反對 回復 2023-12-09
  • 1 回答
  • 0 關注
  • 140 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號