altair,如何使用链接刷创建多面板线图?

时间:2019-06-02 16:49:06

标签: plot interactive altair

我正在尝试修改此Altair图: https://altair-viz.github.io/gallery/scatter_linked_brush.html

我修改了代码,将mark_point()替换为mark_line()。

我希望在间隔区域(图中右侧)中至少突出显示1点的任何行(欧洲,日本,美国)在两个面板中都完全突出显示。但是,间隔选择无法正常工作: Interactive selection not highlighting over plot

代码:

# from https://altair-viz.github.io/gallery/scatter_linked_brush.html 
import altair as alt
from vega_datasets import data

source = data.cars()

brush = alt.selection(type='interval', resolve='global')

base = alt.Chart(source).mark_line().encode(
    y='Miles_per_Gallon',
    color=alt.condition(brush, 'Origin', alt.ColorValue('gray')),
).add_selection(
    brush
).properties(
    width=250,
    height=250
)

base.encode(x='Horsepower') | base.encode(x='Acceleration')

我希望能够跨多个面板突出显示多行。

0 个答案:

没有答案