Concat

hconcat / vconcat.

hconcat / vconcat for side-by-side.

Goal

Run every block and confirm the chart is visible.

df = pd.DataFrame({
    "city": ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret"],
    "units": [21, 15, 15, 18, 12],
    "shillings": [2100, 1500, 1480, 1750, 1190],
})
a = alt.Chart(df).mark_bar().encode(x="city:N", y="units:Q").properties(width=160)
b = alt.Chart(df).mark_bar().encode(x="city:N", y="shillings:Q").properties(width=160)
alt.hconcat(a, b).show()
print("hconcat")
df = pd.DataFrame({
    "city": ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret"],
    "units": [21, 15, 15, 18, 12],
    "shillings": [2100, 1500, 1480, 1750, 1190],
})
a = alt.Chart(df).mark_bar().encode(x="city:N", y="units:Q")
b = alt.Chart(df).mark_circle().encode(x="units:Q", y="shillings:Q")
alt.vconcat(a, b).show()
print("vconcat")
df = pd.DataFrame({
    "month": ["Jan", "Feb", "Mar", "Apr"] * 2,
    "mm": [48, 55, 92, 150, 22, 18, 40, 80],
    "city": ["Nairobi"] * 4 + ["Mombasa"] * 4,
})
alt.Chart(df).mark_line(point=True).encode(x="month:N", y="mm:Q", color="city:N").show()
print("line")
print("concat = next to, not overlay.")