Whisker and box now too
@@ -10,7 +10,9 @@ https://vega.github.io/vega-lite/examples/box-plot_minmax_2D_vertical_normalized
import altair as alt
from vega_datasets import data
-population = data.population.url
+source = data.population()
+
+base = alt.Chart(source)
# Define aggregate fields
lower_box = 'q1(people):Q'
@@ -19,25 +21,25 @@ upper_box = 'q3(people):Q'
upper_whisker = 'max(people):Q'
# Compose each layer individually
-lower_plot = alt.Chart(population).mark_rule().encode(
+lower_plot = base.mark_rule().encode(
y=alt.Y(lower_whisker, axis=alt.Axis(title="population")),
y2=lower_box,
x='age:O'
)
-middle_plot = alt.Chart(population).mark_bar(size=5.0).encode(
+middle_plot = base.mark_bar(size=5.0).encode(
y=lower_box,
y2=upper_box,
x='age:O'
)
-upper_plot = alt.Chart(population).mark_rule().encode(
+upper_plot = base.mark_rule().encode(
y=upper_whisker,
y2=upper_box,
x='age:O'
)
-middle_tick = alt.Chart(population).mark_tick(
+middle_tick = base.mark_tick(
color='white',
size=5.0
).encode(
