Created
October 7, 2022 17:58
-
-
Save jamiepratt/602ce854230d3e87032a269b0204c5bb to your computer and use it in GitHub Desktop.
figuring out how to create a heatmap in vega-lite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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