Last active
May 1, 2020 15:40
-
-
Save BindiChen/0dea2e7fa189f8ff1397180f3b764cc7 to your computer and use it in GitHub Desktop.
An interactive Data Visualization chart using Altair
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import altair as alt | |
from vega_datasets import data | |
cars = data.cars() | |
brush = alt.selection_interval() | |
points = alt.Chart(cars).mark_point().encode( | |
x='Horsepower:Q', | |
y='Miles_per_Gallon:Q', | |
color=alt.condition(brush, 'Origin:N', alt.value('lightgray')) | |
).add_selection( | |
brush | |
) | |
bars = alt.Chart(cars).mark_bar().encode( | |
y='Origin:N', | |
color='Origin:N', | |
x='count(Origin):Q' | |
).transform_filter( | |
brush | |
) | |
points & bars |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment