Tableplot
Easy layered graphics with Hanami & Tablecloth
-> datasets/economics-long
(-> % :variable (= "unemploy")))
(tc/select-rows #(:date
(hanami/base {:=x :value})
:=y "purple"})
(hanami/layer-line {:=mark-color 5)
(hanami/update-data tc/random "green"
(hanami/layer-point {:=mark-color 200})) :=mark-size
See more examples:
Plotly API Walkthrough π£ - experimental π
1 Preface
Tableplot is a composition of Hanami data visualization templates and Tablecloth datasets.
It adds a simplified set of Hanami templates and defaults alongside those of Hanami, as well as a set of template-processing functions inspired by ggplot2βs layered grammar of graphics.
The current draft was written by Daniel Slutsky, mentored by jsa-aerial (Hanami author) and Kira McLean.
Status: The API is almost stable and will soon move to beta stage.
An early version of this library was demonstrated in Kira Mcleanβs April 2024 talk at London Clojurians:
1.1 Two APIs
Tableplot currently supports two APIs:
scicloj.tableplot.v1.hanami
generates Vega-Lite plots and parially composes with the classic Hanami templates.scicloj.tableplot.v1.plotly
generates the Plotly.js plots.
Each of these APIs builds upon the strengths of its target platform and partially uses its naming and concepts. Thus, the two APIs are not completely compatible. The Plotly-based API is expected to grow a little further in terms of its flexibility and the kinds of idioms it can express.
1.2 Near term plan
- Stabilize both the Vega-Lite-based API and the Plotly.js-based API as Beta stage.
- Keep developing main ly the Plotly.js-based API (as it will be more flexible to extend).
1.3 Goals
- Have a functional grammar for common plotting tasks (but not all tasks).
- In particular, provide an easy way to work with layers.
- Be able to pass Tablecloth/tech.ml.dataset datasets directly to the plotting functions.
- Work out-of-the box in Kindly-supporting tools.
- By default, infer relevant information from the data (e.g., field types).
- Catch common errors using the data (e.g., missing fields).
- Be able to use backend Clojure for relevant statistical tasks (e.g., smoothing by regression, histograms, density estimation).
- Be able to rely on Vega-Lite/Plotly.js for other some components of the pipeline (e.g., scales and coordinates).
- Provide simpler Hanami templates, compared to the original ones.
- Still have the option of using the original Hanami templates.
- Still be able to use all of Vega-Lite/Plotly.js in its raw format for the highest flexibility.
In the longer term, this project is part of the Scicloj effort to create a grammar-of-graphics visualization library in Clojure.
1.4 Discussion
- development - topic threads under #tableplot-dev at the Clojurians Zulip chat or Github Issues
- usage - topic threads under #data-science
1.5 Chapters in this book:
source: notebooks/index.clj