Transforming Datasets to Stack Charts
A couple of quick ideas about visualizing data, especially with regard to comparison.
Keywords
charts, datasets
With observed data, presumably from two runs of some experiment…
def ds0
("https://gist.githubusercontent.com/harold/18ba174c6c34e7d1c5d8d0954b48327c/raw"
(ds/->dataset :file-type :csv})) {
def ds1
("https://gist.githubusercontent.com/harold/008bbcd477bf51b47548d680107a6195/raw"
(ds/->dataset :file-type :csv})) {
Well, what have we got?
ds0
https://gist.githubusercontent.com/harold/18ba174c6c34e7d1c5d8d0954b48327c/raw [500 1]:
y |
---|
-0.09138541 |
0.73573478 |
0.66637442 |
1.42894310 |
1.17985915 |
2.10245096 |
2.35628501 |
1.65951387 |
2.66932952 |
1.96287689 |
… |
6.30911743 |
6.65394635 |
5.88407917 |
6.59312352 |
6.32078823 |
5.78220740 |
6.11383638 |
6.62701870 |
6.29688536 |
5.87255145 |
6.34171349 |
A few hundred numbers… Hm…
ds1
https://gist.githubusercontent.com/harold/008bbcd477bf51b47548d680107a6195/raw [500 1]:
y |
---|
1.23590349 |
0.97176804 |
1.44779983 |
2.09836076 |
2.39260885 |
2.33861635 |
2.55252144 |
2.75108032 |
3.42274612 |
3.13478376 |
… |
22.45761328 |
22.35632666 |
21.93285307 |
22.24006990 |
22.51064120 |
22.38858256 |
22.53949283 |
22.57957379 |
22.31971585 |
22.69953383 |
22.23848485 |
This neglects the hundreds of thousands of years invested in evolving a visual system…
-> ds0
("Run 0"})
(plotly/base {:=title "y"})) (plotly/layer-point {:=y
-> ds1
("Run 1"})
(plotly/base {:=title "y"})) (plotly/layer-point {:=y
Better; however, our aim is to compare them… Which is higher?
-> (ds/concat (assoc ds0 :v "Run 0")
(assoc ds1 :v "Run 1"))
("Comparison Between Runs"})
(plotly/base {:=title "y"
(plotly/layer-point {:=y :v})) :=color
Now it’s up to the viewer to decide whether they like higher numbers or not.
There are a couple of interesting ideas in that last bit of code:
assoc
a constant onto a ds creates a constant column:=color
takes care of grouping the results and the downstream display
Neat.