Skip to content
Heatmap

Heatmap

A heatmap.

Heatmap

Usage

from dataviz_mojo import heatmap
from dataviz_mojo.plot import save
from dataviz_mojo.theme import Theme

def main() raises:
    var days: List[String] = ["Mon", "Mon", "Mon", "Tue", "Tue", "Tue", "Wed", "Wed", "Wed"]
    var hours: List[String] = ["9am", "1pm", "5pm", "9am", "1pm", "5pm", "9am", "1pm", "5pm"]
    var activity: List[Float64] = [3.0, 8.0, 5.0, 4.0, 9.0, 6.0, 2.0, 7.0, 10.0]

    var c = heatmap(days, hours, activity)
    save(c, "docs/src/examples/out_heatmap.svg")

Args:

  • x: Each cell’s column category, one entry per row of data.
  • y: Each cell’s row category, one entry per row of data.
  • value: Each cell’s value, mapped through a continuous color gradient.
  • theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – see Theme’s docstring.
  • width: Pixel width of the returned Plot (.size()).
  • height: Pixel height of the returned Plot (.size()).
  • title: The chart’s title, shown above the plot.
  • subtitle: A secondary line shown under the title.
  • x_title: The x-axis caption.
  • y_title: The y-axis caption.