[問題] plotly 多層繪圖問題

看板Python作者 (蘇打)時間5年前 (2018/10/30 18:28), 編輯推噓1(102)
留言3則, 2人參與, 5年前最新討論串1/1
python 3.7 版 各位版友好 最近想要將多張圖表透過 plotly 呈現 程式大概如下: from plotly import tools import plotly.graph_objs as go trace1 = go.Bar(...) trace2_1 = go.Scatter(...) trace2_2 = go.Scatter(...) trace2_3 = go.Scatter(...) trace2 = [trace2_1, trace2_2, trace2_3] 單獨繪製 trace1 or trace2 都是正常的 但我想要將所有資料呈現在同個畫面 (trace1, trace2 的x軸共用) fig = tools.make_subplots(rows=2, cols=1, specs=[[{}],[{}]], shared_xaxes=True, shared_yaxes=True, vertical_spacing=0.001) fig.append_trace(trace1 , 1, 1) fig.append_trace(trace2 , 2, 1) <-- 失敗 fig.append_trace(trace2_1, 2, 1) <-- 成功 看起來是 specs 描述上的錯誤 但我嘗試修改成 [[{}],[{},{},{}]] 等方式也失敗 想請問 specs 該如何描述才能讓程式認得多層的圖形呢 另外能否在滑鼠移動時同時顯示不同 trace 的數值 (例如 https://plot.ly/python/axes/ ,但改用 subplots 的方式) 感謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.169.80.35 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1540895296.A.2ED.html

10/30 18:44, 5年前 , 1F
第一題自問自答 ... 改用 overlay
10/30 18:44, 1F

10/31 11:42, 5年前 , 2F
subfig should work
10/31 11:42, 2F

10/31 11:43, 5年前 , 3F
sorry, i mean subplot
10/31 11:43, 3F
文章代碼(AID): #1Rs390Bj (Python)