In [4]:
import IPython.display
def vegify(spec):
IPython.display.display({
'application/vnd.vegalite+json': spec.to_dict()
}, raw=True)
In [5]:
from altair import Chart, load_dataset
# load data as a pandas DataFrame
cars = load_dataset('cars')
spec = Chart(cars).mark_point().encode(
x='Horsepower',
y='Miles_per_Gallon',
color='Origin',
)
vegify(spec)
In [ ]: