将 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
提交
取消
