簡體   English   中英

無論如何,在Altair中是否會彈出部分地圖或更改顏色

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

我正在嘗試在altair中繪制印度州。我能夠繪制圖形並在工具提示中顯示州名稱。我希望該州在選擇時彈出或更改顏色。是否有任何方法可以這樣做。

我嘗試使用selection_interval。但是由於我是新手而無法做到

'''蟒蛇

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

)

您可以使用具有條件顏色的單一選擇來執行以下操作:

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
)

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM