Tableplot
Easy layered graphics with Hanami & Tablecloth
-> datasets/economics-long
(-> % :variable (= "unemploy")))
(tc/select-rows #(:date
(plotly/base {:=x :value})
:=y "purple"})
(plotly/layer-line {:=mark-color 5)
(plotly/update-data tc/random "green"
(plotly/layer-point {:=mark-color 20})) :=mark-size
See more examples:
1 Preface 👋
Tableplot is a Clojure library for data visualization inspired by ggplot2’s layered grammar of graphics.
It is built to be composable with Tablecloth table processing and extend the plotting templates of Hanami.
Tableplot works with any tool that supports the Kindly data visualization standard, such as Clay.
1.1 Two APIs
Tableplot currently supports two APIs:
scicloj.tableplot.v1.plotly
generates the Plotly.js plots.scicloj.tableplot.v1.hanami
generates Vega-Lite plots and parially composes with the original Hanami templates.
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 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 simple Hanami templates in addition 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 their 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.3 Discussion
- development - topic threads under #tableplot-dev at the Clojurians Zulip chat or Github Issues
- usage - topic threads under #data-science
1.4 Chapters in this book:
source: notebooks/index.clj