Skip to content

Instantly share code, notes, and snippets.

@jamiepratt
Created October 7, 2022 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiepratt/602ce854230d3e87032a269b0204c5bb to your computer and use it in GitHub Desktop.
Save jamiepratt/602ce854230d3e87032a269b0204c5bb to your computer and use it in GitHub Desktop.
figuring out how to create a heatmap in vega-lite
(ns heatmap
(:require [nextjournal.clerk :as clerk]
[aerial.hanami.common :as hc]
[aerial.hanami.templates :as ht])
)
(defn heat-map-graph [title data]
(hc/xform ht/heatmap-chart
:TITLE title
:DATA data
:X "mu"
:XTYPE "nominal"
:Y "sd"
:YTYPE "nominal"
:COLOR {:field "ll" :type "quantitative" :title "Likelihood"}
:YSCALE {:zero false}
:XSCALE {:zero false}
:TOOLTIP [{:field "ll" :title "Likelihood" :type "quantitative"}
{:field "mu" :type "quantitative"}
{:field "sd" :type "quantitative"}]))
ht/heatmap-chart
(heat-map-graph "" [])
(clerk/vl (heat-map-graph "testing"
(for [mu (range 0 40)
sd (range 0 40)
]
{:mu mu
:sd sd
:ll (+ mu (* 40 sd))})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment