可能的解决方案包括使用 .interactive() 方法或更改 tooltip 参数的值。
示例代码:
import altair as alt
from vega_datasets import data
source = data.cars()
# 当鼠标悬停在散点图上时,不显示工具提示
alt.Chart(source).mark_point().encode(
x='Horsepower',
y='Miles_per_Gallon'
)
# 使用interactive()方法,使工具提示可见
alt.Chart(source).mark_point().encode(
x='Horsepower',
y='Miles_per_Gallon'
).interactive()
# 更改Tooltip参数的值,自定义工具提示的键值对
alt.Chart(source).mark_point().encode(
x='Horsepower',
y='Miles_per_Gallon',
tooltip=['Name', 'Horsepower', 'Miles_per_Gallon']
).interactive()