Skip to content

I ask for help on how to implement an example with a histogram from 'vega-lite' in 'altair' #3295

Discussion options

You must be logged in to vote

Does something like this give you something like what you want?

I based it on this example, which I found by searching the Altair documentation for the word hover, which is at the very bottom of the Vega spec you linked.

import altair as alt
import pandas as pd

df = pd.DataFrame({
    "x": range(5),
    "y": range(5)
})

hover = alt.selection_point(on='mouseover', nearest=False,
                      fields=['x', 'y'], empty=False)

alt.Chart(df).mark_bar().encode(
    x = "x:N",
    y = "y:Q",
    color = alt.condition(hover, alt.value('red'), alt.value('blue'))
).add_params(hover)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@mattijn
Comment options

@Piskuliki0723
Comment options

@ChristopherDavisUCI
Comment options

Answer selected by Piskuliki0723
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants