Skip to content

Commit 664a113

Browse files
committed
composable plotting wip
1 parent f67ced8 commit 664a113

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

src/data_visualization/aog/composable_plotting.clj

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
^{:kindly/hide-code true
22
:clay {:title "Composable Plotting in Clojure"
33
:quarto {:type :post
4-
:author [:daslu :claude]
5-
:date "2026-02-22"
4+
:author [:daslu]
5+
:date "2026-03-03"
66
:description "Building a composable plotting API in Clojure, from views and layers to scatterplot matrices"
77
:category :data-visualization
88
:tags [:datavis :grammar-of-graphics :design :wadogo]
@@ -1351,8 +1351,9 @@ tips
13511351
global-y-doms (or (:domain y-scale-spec)
13521352
(when (#{:shared :free-x} scale-mode)
13531353
(compute-global-y-domain stat-results views y-scale-spec)))
1354-
;; Axis labels: auto-infer unless multi-variable (SPLOM), allow override
1355-
auto-label? (not multi?)
1354+
;; Axis labels: auto-infer unless multi-variable (SPLOM) or
1355+
;; coord system has no rectangular axes (e.g. polar), allow override
1356+
auto-label? (and (not multi?) (show-ticks? coord-type-main))
13561357
eff-x-label (or x-label
13571358
(:label x-scale-spec)
13581359
(when auto-label?
@@ -2915,6 +2916,41 @@ tips
29152916
;;
29162917
;; ---
29172918

2919+
;; ## Putting It All Together
2920+
;;
2921+
;; The examples above introduce features one at a time. These final
2922+
;; examples combine several at once, showing that the composition
2923+
;; works freely -- polar with faceting, layers with facet grids --
2924+
;; without any special-case code.
2925+
2926+
;; ### 🧪 Polar Rose by Year
2927+
;;
2928+
;; Stacked bars in polar coordinates, faceted by year.
2929+
;; Each wedge shows a vehicle class; color distinguishes drivetrain.
2930+
;; Comparing the two panels reveals how class distributions shifted
2931+
;; between 1999 and 2008:
2932+
2933+
;; :::{.column-screen-inset-right}
2934+
(-> (view mpg :class)
2935+
(lay (stacked-bar {:color :drv}))
2936+
(coord :polar)
2937+
(facet :year)
2938+
(plot {:width 800 :height 400}))
2939+
;; :::
2940+
2941+
;; ### 🧪 Scatter with Regression, Faceted Grid
2942+
;;
2943+
;; Tips vs. total bill, colored by meal time, with a regression
2944+
;; line per group. `facet-grid` splits by smoker status (rows) and
2945+
;; sex (columns) -- four panels, each with its own scatter and fit:
2946+
2947+
(-> (view tips [[:total-bill :tip]])
2948+
(lay (point {:color :time}) (lm {:color :time}))
2949+
(facet-grid :smoker :sex)
2950+
(plot {:width 600 :height 500}))
2951+
2952+
;; ---
2953+
29182954
;; ## Reflection
29192955
;;
29202956
;; ### 📖 What seemed to work

0 commit comments

Comments
 (0)