Macroexpand 2025 Noj: Civitas Workshop
:clay {:title "Macroexpand 2025 Noj: Civitas Workshop"
^{:quarto {:author :timothypratley
:image "macroexpand_workshop_tableplot.png"
:type :post
:date "2025-10-17"
:category :clay
:tags [:clay :workflow]}}}
ns scicloj.tableplot.ideas.macroexpand-workshop-tableplot
(:require [tablecloth.api :as tc]
(:as tp])) [scicloj.tableplot.v1.plotly
We built this code in the Civitas Workshop. We selected Tableplot as the topic to write about.
Everything about Tableplot is inspired by R, there everything is about tables - dataframes. We hope to have our own version of that.
It is a limitation at the moment to require a dataset.
def scatter-ds
(:x [1 2 3 4 5]
(tc/dataset {:y [10 20 15 25 18]
:z [1 2 1 2 1]}))
We call tableplot on the dataset:
-> scatter-ds
("Sample Scatter Plot"})
(tp/base {:=title :x
(tp/layer-point {:=x :y})) :=y
Why is the plot not Kindly annotated? Tableplot returns annotated values.
-> scatter-ds
("Sample Scatter Plot"})
(tp/base {:=title :x
(tp/layer-point {:=x :y})
:=y meta)) (
:kindly{:kind :kind/fn, :options nil} #
The kind is :kind/fn
which is a transformation. Where is the function?
-> scatter-ds
("Sample Scatter Plot"})
(tp/base {:=title :x
(tp/layer-point {:=x :y})
:=y :kindly/f)) (
#'scicloj.tableplot.v1.plotly/plotly-xform
hidden in the value is the :kindly/f
.
Other types of plots:
Using layer-bar instead of layer-point
-> scatter-ds
("Sample Scatter Plot"})
(tp/base {:=title :x
(tp/layer-bar {:=x :y})) :=y
We can plot different columns of the dataset as layers.
-> scatter-ds
("Sample Scatter Plot"})
(tp/base {:=title :x
(tp/layer-line {:=x :z})
:=y :x
(tp/layer-bar {:=x :y})) :=y
You don’t need a big idea to write a Civitas post, small explorations are welcome.