Skip to content

Commit 872dcc3

Browse files
committed
[scicloj/tableplot/ideas/stacking] First draft
1 parent e1b9d06 commit 872dcc3

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

site/db.edn

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@
4242
:image "https://avatars.githubusercontent.com/u/49298?v=4"
4343
:email "timothypratley@gmail.com"
4444
:affiliation [:hummi]
45-
:links [{:icon "github" :href "https://github.com/timothypratley"}]}]
45+
:links [{:icon "github" :href "https://github.com/timothypratley"}]}
46+
{:id :harold
47+
:name "Harold"
48+
:url "https://techascent.com"
49+
:image "https://avatars.githubusercontent.com/u/7443?v=4"
50+
:email "harold@techascent.com"
51+
:affiliation [:techascent]
52+
:links [{:icon "github" :text "GitHub" :href "https://github.com/harold"}]}]
4653

4754
:affiliation
4855
[{:id :clojure.core
@@ -57,7 +64,10 @@
5764
{:id :hummi
5865
:name "Hummi"
5966
;; TODO: as icons
60-
:url "https://hummi.app"}]
67+
:url "https://hummi.app"}
68+
{:id :techascent
69+
:name "TechAscent"
70+
:url "https://techascent.com"}]
6171

6272
:topic
6373
[{:id :core
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
^{:kindly/hide-code true
2+
:clay {:title "Transforming Datasets to Stack Charts"
3+
:quarto {:type :post
4+
:author [:harold]
5+
:date "2025-06-24"
6+
:description "A couple of quick ideas about visualizing data, especially with regard to comparison."
7+
:category :datasets
8+
:tags [:charts :datasets]
9+
:keywords [:charts :datasets]}}}
10+
(ns scicloj.tableplot.ideas.stacking
11+
(:require [tech.v3.dataset :as ds]
12+
[scicloj.tableplot.v1.plotly :as plotly]))
13+
14+
;; With observed data, presumably from two runs of some experiment...
15+
16+
(def ds0
17+
(ds/->dataset "https://gist.githubusercontent.com/harold/18ba174c6c34e7d1c5d8d0954b48327c/raw"
18+
{:file-type :csv}))
19+
20+
(def ds1
21+
(ds/->dataset "https://gist.githubusercontent.com/harold/008bbcd477bf51b47548d680107a6195/raw"
22+
{:file-type :csv}))
23+
24+
;; Well, what have we got?
25+
26+
ds0
27+
28+
;; A few hundred numbers... Hm...
29+
30+
ds1
31+
32+
;; This neglects the hundreds of thousands of years invested in evolving a visual system...
33+
34+
(-> ds0
35+
(plotly/base {:=title "Run 0"})
36+
(plotly/layer-point {:=y "y"}))
37+
38+
(-> ds1
39+
(plotly/base {:=title "Run 1"})
40+
(plotly/layer-point {:=y "y"}))
41+
42+
;; Better; however, our aim is to compare them... Which is higher?
43+
44+
(-> (ds/concat (assoc ds0 :v "Run 0")
45+
(assoc ds1 :v "Run 1"))
46+
(plotly/base {:=title "Comparison Between Runs"})
47+
(plotly/layer-point {:=y "y"
48+
:=color :v}))
49+
50+
;; Now it's up to the viewer to decide whether they like higher numbers or not.
51+
52+
;; ---
53+
54+
;; There are a couple of interesting ideas in that last bit of code:
55+
;;
56+
;; 1. `assoc` a constant onto a ds creates a constant column
57+
;; 1. `:=color` takes care of grouping the results and the downstream display
58+
59+
;; Neat.

0 commit comments

Comments
 (0)