|
1 | 1 | ^{:kindly/hide-code true |
2 | 2 | :clay {:title "Composable Plotting in Clojure" |
3 | 3 | :quarto {:type :post |
4 | | - :author [:daslu :claude] |
5 | | - :date "2026-02-22" |
| 4 | + :author [:daslu] |
| 5 | + :date "2026-03-03" |
6 | 6 | :description "Building a composable plotting API in Clojure, from views and layers to scatterplot matrices" |
7 | 7 | :category :data-visualization |
8 | 8 | :tags [:datavis :grammar-of-graphics :design :wadogo] |
@@ -1351,8 +1351,9 @@ tips |
1351 | 1351 | global-y-doms (or (:domain y-scale-spec) |
1352 | 1352 | (when (#{:shared :free-x} scale-mode) |
1353 | 1353 | (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)) |
1356 | 1357 | eff-x-label (or x-label |
1357 | 1358 | (:label x-scale-spec) |
1358 | 1359 | (when auto-label? |
@@ -2915,6 +2916,41 @@ tips |
2915 | 2916 | ;; |
2916 | 2917 | ;; --- |
2917 | 2918 |
|
| 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 | + |
2918 | 2954 | ;; ## Reflection |
2919 | 2955 | ;; |
2920 | 2956 | ;; ### 📖 What seemed to work |
|
0 commit comments