Public
Edited
May 10, 2022
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
chart_spec = py`# start with a fake dependency on the libraries being installed:
# ${deps_installed}

# now the basic altair example:
import altair as alt
import json
from vega_datasets import data
cars = data.cars.url

chart = alt.Chart(cars).mark_point().encode(
x=alt.X('Horsepower:Q', scale=alt.Scale(domain=[0, ${max_horsepower}])),
y='Miles_per_Gallon:Q',
color='Origin:N',
).interactive()

# this outputs Map, not Object:
# chart.to_dict()
# which, we could probably correct for directly
# for now, we'll take the hit of encoding and recoding it to JSON:
json.dumps(chart.to_dict())`
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more