將 2 個圖表與它們自己的滑塊連接時,滑塊最后會組合在一起。有沒有辦法讓每個情節都保留滑塊?這是一個示例,從文檔修改import altair.vegalite.v3 as altimport pandas as pdimport numpy as nprand = np.random.RandomState(42)df = pd.DataFrame({"xval": range(100), "yval": rand.randn(100).cumsum()})slider1 = alt.binding_range(min=0, max=100, step=1, name="cutoff1:")selector1 = alt.selection_single( name="SelectorName1", fields=["cutoff1"], bind=slider1, init={"cutoff1": 50})slider2 = alt.binding_range(min=0, max=100, step=1, name="cutoff2:")selector2 = alt.selection_single( name="SelectorName2", fields=["cutoff2"], bind=slider2, init={"cutoff2": 50})ch_base = ( alt.Chart(df) .mark_point() .encode( x="xval", y="yval", color=alt.condition( alt.datum.xval < selector1.cutoff1, alt.value("red"), alt.value("blue") ), ))ch1 = ch_base.add_selection(selector1)ch2 = ch_base.encode( color=alt.condition( alt.datum.xval < selector2.cutoff2, alt.value("red"), alt.value("blue") )).add_selection(selector2)ch1 & ch2如圖所示,默認情況下,滑塊彼此相鄰分組:
1 回答

慕斯王
TA貢獻1864條經驗 獲得超2個贊
滑塊總是出現在整個圖表的底部。目前沒有辦法改變這一點。
如果您希望此功能在未來存在,我建議您在 Vega-Lite 中提交功能請求。
作為一種解決方法,您可以創建兩個圖表,并使用vega-embed將它們嵌入到單個文檔中,盡管這樣做時在兩個圖表之間傳遞信號并非易事。
添加回答
舉報
0/150
提交
取消