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
(ds/->dataset "https://gist.githubusercontent.com/harold/18ba174c6c34e7d1c5d8d0954b48327c/raw"
{:file-type :csv}))(def ds1
(ds/->dataset "https://gist.githubusercontent.com/harold/008bbcd477bf51b47548d680107a6195/raw"
{:file-type :csv}))Well, what have we got?
ds0https://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…
ds1https://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
(plotly/base {:=title "Run 0"})
(plotly/layer-point {:=y "y"}))(-> ds1
(plotly/base {:=title "Run 1"})
(plotly/layer-point {:=y "y"}))Better; however, our aim is to compare them… Which is higher?
(-> (ds/concat (assoc ds0 :v "Run 0")
(assoc ds1 :v "Run 1"))
(plotly/base {:=title "Comparison Between Runs"})
(plotly/layer-point {:=y "y"
:=color :v}))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:
assoca constant onto a ds creates a constant column:=colortakes care of grouping the results and the downstream display
Neat.