Heatmap

mark_rect.

mark_rect.

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],
})
chart = (alt.Chart(df).mark_rect().encode(x="city:N", y="units:Q", color="shillings:Q")).properties(width=360, height=220, title='heat')
chart.show()
print('heat')
df = pd.DataFrame({
    "city": ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret"],
    "units": [21, 15, 15, 18, 12],
    "shillings": [2100, 1500, 1480, 1750, 1190],
})
(alt.Chart(df).mark_rect().encode(x="city:N", y="units:Q", color="shillings:Q")).properties(width=320, height=200).show()
print("again")
df = pd.DataFrame({
    "city": ["Nairobi", "Mombasa", "Kisumu", "Nakuru", "Eldoret"],
    "units": [21, 15, 15, 18, 12],
    "shillings": [2100, 1500, 1480, 1750, 1190],
})
alt.Chart(df).mark_bar().encode(x="city:N", y="units:Q").show()
print("bar")
print('heat')