Rect heatmap¶
A dense quantitative grid rendered with rect marks and a continuous color scale.
Code¶
"""Rect heatmap.
A dense quantitative grid rendered with rect marks and a continuous color
scale.
"""
import genome_spy as gs
from genome_spy.datasets._grammar import heatmap_data
from genome_spy.schema import Scale
# Load a small grid of example values.
data = heatmap_data()
# Draw one colored tile per cell, with color showing its value.
chart = (
gs.Chart(data)
.mark_rect()
.encode(
x=gs.X("x:O").axis(None),
y=gs.Y("y:O").axis(None),
color=gs.Color("z:Q").scale(Scale(scheme="magma")).title("value"),
)
.properties(title="Rect heatmap")
)