无论如何,在 Altair 中选择时是否会弹出部分地图或更改颜色

Is there anyway to popping out of part of Map or change of color on selection in Altair

我正在尝试绘制 altair.I 中的印度各州 我能够绘制并且工具提示中的州名称是 appearing.I 希望该州在 [=19 上弹出或改变颜色=] 有什么办法可以做到。

我尝试使用 selection_interval.But 因为我是新手所以无法使用

'''python

import altair as alt

url = "https://raw.githubusercontent.com/deldersveld/topojson/master/countries/india/india-states.json"

source = alt.topo_feature(url, "IND_adm1")

alt.Chart(source).mark_geoshape().encode(
    tooltip='properties.NAME_1:N',
    color=alt.value('lightgray')   

).properties(
        width=800,
        height=500

)

您可以使用带有条件颜色的 Single Selection 来执行如下操作:

import altair as alt

url = "https://raw.githubusercontent.com/deldersveld/topojson/master/countries/india/india-states.json"

source = alt.topo_feature(url, "IND_adm1")
hover = alt.selection_single(on='mouseover', empty='none')

alt.Chart(source).mark_geoshape().encode(
    tooltip='properties.NAME_1:N',
    color=alt.condition(hover, alt.value('steelblue'), alt.value('lightgray'))
).properties(
    width=800,
    height=500
).add_selection(
    hover
)