2
我已加入到圖像表示我的問題:創建具有雙軸線的曲線圖,但與範圍不連接在一起,並用自動縮放
- 僅具有一個軸線和一個數據系列的曲線圖。
- 兩軸圖(底部的線與第一個圖中的線相同)。
我使用小部件和散景服務器爲了讓用戶玩不同的選項顯示不同的數據系列。
正如您在下面的代碼中看到的,我已經在兩個範圍中都使用了DataRange1d,但即使在使用小部件更改方案時兩個軸都會自動縮放,但這些軸會保持鏈接在一起,覆蓋的範圍相同有什麼關係。
我在文檔中搜索和唯一的解決方案,我發現我的問題是將一個特定的範圍傳遞給Range1d或DataRange1d。我無法做到這一點,因爲我有很多數據系列要展示,所以一個範圍不適合所有人。
謝謝!
代碼:
#create plots
p_balance = figure(width=500, height=300, title='Balance', tools='save')
p_total_debt = figure(width=500, height=300, title='Total debt', tools='save')
p_both = figure(width=1000, height=300, title='Both', tools='save')
#add the second axis
p_both.y_range = DataRange1d()
p_both.extra_y_ranges = {'total debt': DataRange1d()}
p_both.add_layout(LinearAxis(y_range_name='total debt'), 'right')
#add glyphs
line_balance = p_balance.line(x=list(range(0,26)), y='y', source=source_balance, color='black', line_width=2)
line_total_debt = p_total_debt.line(x=list(range(0,26)), y='y', source=source_total_debt, color='black', line_width=2)
#for the second plot with both series
line_balance2 = p_both.line(x=list(range(0,26)), y='y', source=source_balance, color='black', line_width=2)
line_total_debt = p_both.line(x=list(range(0,26)), y='y', source=source_total_debt, color='black', line_width=2, y_range_name='total debt')
@etigrenier。這能解決你的問題嗎? – renzop