38 Lattice
The figures of Deepayan Sarkar’s Lattice: Multivariate Data Visualization with R (Springer 2008), rebuilt with cljplot2 - a section per chapter, a block per figure. The R code of every figure is on the book’s figures page; each block links its figure there.
The figures show the same information as the originals; styling differs, and the code is cljplot2’s own (plain plot maps, data prepared in Clojure). Lattice’s banking (aspect = "xy") is replaced by the image size, its strips by cljplot2 facet strips. Lattice fills panels from the bottom row up; here they run top-down, so panels stacked in rows and ordered by a statistic put the largest first to look the same. 3D boxes are drawn in perspective at lattice’s distance of 0.2 (:view {:distance 0.2}; cljplot2’s default is orthographic), from lattice’s views: screen = list(z = θ, x = φ) is :view {:azimuth -θ :elevation (90 + φ)} (the default z = 40, x = -60 - azimuth -40, elevation 30). Data are the book’s, exported from R (see the dataset notes under each figure).
Not here: chapter 12 (interactive displays) and a few figures outside the medium - each is listed in its chapter.
(ns galleries.lattice
(:require [clojure.string :as str]
[fastmath.core :as m]
[fastmath.interpolation :as interp]
[fastmath.kernel :as k]
[fastmath.ml.clustering :as cl]
[fastmath.ml.regression :as regression]
[fastmath.random :as r]
[fastmath.stats :as stats]
[cljplot2.chart :as chart]
[cljplot2.core :as plot]
[cljplot2.data.contour :as contour]
[cljplot2.data.levels :as levels]
[cljplot2.data.shingle :as shingle]
[cljplot2.data.tree :as tree]
[notebook-utils :as nu]))(def two-colors
"Two contrasting colours for two groups (the default palette's first two are both blue)."
[[31 119 180] [214 39 40]])(defn- figure-url
"Permalink of LMDVR figure `chapter`.`figure` on the book's figures page."
[chapter figure]
(format "http://lmdvr.r-forge.r-project.org/figures/figures.html?chapter=%02d;figure=%02d_%02d;theme=stdColor;code=right"
chapter chapter figure))#'galleries.lattice/figure-url(def chem97 (nu/dataset :chem97))| lea | school | student | score | gender | age | gcsescore | gcsecnt |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 4 | F | 3 | 6.625 | 0.33931571143033 |
| 1 | 1 | 2 | 10 | F | -3 | 7.625 | 1.33931571143033 |
| 1 | 1 | 3 | 10 | F | -4 | 7.25 | 0.96431571143033 |
| 1 | 1 | 4 | 10 | F | -2 | 7.5 | 1.21431571143033 |
| 1 | 1 | 5 | 8 | F | -1 | 6.444 | 0.15831571143033 |
| 1 | 1 | 6 | 10 | F | 4 | 7.75 | 1.46431571143033 |
| 1 | 1 | 7 | 6 | F | 1 | 6.75 | 0.46431571143033 |
| 1 | 1 | 8 | 8 | F | 4 | 6.909 | 0.62331571143033 |
| 1 | 1 | 9 | 4 | F | 3 | 6.375 | 0.0893157114303298 |
| 1 | 1 | 10 | 10 | F | 0 | 7.75 | 1.46431571143033 |
| 1 | 1 | 11 | 10 | F | -1 | 7.857 | 1.57131571143033 |
| 1 | 1 | 12 | 8 | F | 1 | 7.333 | 1.04731571143033 |
| 1 | 1 | 13 | 10 | F | 1 | 7.75 | 1.46431571143033 |
| 1 | 2 | 14 | 10 | M | 0 | 7.7 | 1.41431571143033 |
| 1 | 2 | 15 | 10 | M | -4 | 6.3 | 0.0143157114303296 |
| 1 | 2 | 16 | 10 | M | 5 | 7.3 | 1.01431571143033 |
| 1 | 2 | 17 | 8 | M | -3 | 6.636 | 0.35031571143033 |
| 1 | 2 | 18 | 10 | M | 4 | 7.272 | 0.98631571143033 |
| 1 | 2 | 19 | 10 | M | 0 | 7.2 | 0.91431571143033 |
| 1 | 2 | 20 | 4 | M | -3 | 6.454 | 0.16831571143033 |
| 1 | 2 | 21 | 6 | M | 4 | 6.818 | 0.532315711430329 |
| 1 | 2 | 22 | 10 | M | -5 | 7.3 | 1.01431571143033 |
| 1 | 2 | 23 | 2 | M | -1 | 6.2 | -0.08568428856967 |
| 1 | 2 | 24 | 10 | M | -2 | 7.111 | 0.82531571143033 |
| 1 | 2 | 25 | 10 | M | 2 | 6.8 | 0.51431571143033 |
| 1 | 2 | 26 | 8 | M | -4 | 6.5 | 0.21431571143033 |
| 1 | 2 | 27 | 10 | M | -5 | 6.727 | 0.44131571143033 |
| 1 | 2 | 28 | 6 | M | -6 | 7 | 0.71431571143033 |
| 1 | 2 | 29 | 10 | M | -2 | 7.7 | 1.41431571143033 |
| 1 | 2 | 30 | 10 | M | 3 | 7.3 | 1.01431571143033 |
| 1 | 2 | 31 | 8 | M | 3 | 6.4 | 0.11431571143033 |
| 1 | 2 | 32 | 10 | M | 2 | 6.833 | 0.54731571143033 |
| 1 | 2 | 33 | 10 | M | 2 | 7.363 | 1.07731571143033 |
| 1 | 2 | 34 | 4 | M | 5 | 6.6 | 0.314315711430329 |
| 1 | 2 | 35 | 10 | M | -1 | 7.6 | 1.31431571143033 |
| 1 | 2 | 36 | 10 | M | -2 | 7.555 | 1.26931571143033 |
| 1 | 2 | 37 | 10 | M | 0 | 7.7 | 1.41431571143033 |
| 1 | 2 | 38 | 10 | M | -5 | 7.7 | 1.41431571143033 |
| 1 | 2 | 39 | 8 | M | -5 | 6 | -0.28568428856967 |
| 1 | 2 | 40 | 10 | M | 3 | 8 | 1.71431571143033 |
| 1 | 2 | 41 | 10 | M | -6 | 6.6 | 0.314315711430329 |
| 2 | 3 | 42 | 8 | F | 3 | 6.555 | 0.26931571143033 |
| 2 | 3 | 43 | 0 | F | -1 | 4.75 | -1.53568428856967 |
| 2 | 3 | 44 | 6 | M | 0 | 4.625 | -1.66068428856967 |
| 2 | 4 | 45 | 6 | M | 0 | 5.25 | -1.03568428856967 |
| 2 | 4 | 46 | 10 | M | 5 | 6 | -0.28568428856967 |
| 2 | 4 | 47 | 10 | M | -3 | 6.375 | 0.0893157114303298 |
| 2 | 4 | 48 | 10 | M | 1 | 6.75 | 0.46431571143033 |
| 2 | 4 | 49 | 2 | M | 3 | 6 | -0.28568428856967 |
| 2 | 4 | 50 | 10 | M | 3 | 6.25 | -0.0356842885696702 |
| 2 | 4 | 51 | 10 | F | 3 | 7 | 0.71431571143033 |
| 2 | 5 | 52 | 8 | M | 5 | 6.25 | -0.0356842885696702 |
| 2 | 5 | 53 | 0 | F | 3 | 4.285 | -2.00068428856967 |
| 2 | 5 | 54 | 6 | M | -2 | 6.75 | 0.46431571143033 |
| 2 | 5 | 55 | 4 | M | 4 | 6.375 | 0.0893157114303298 |
| 2 | 5 | 56 | 6 | M | -2 | 6.777 | 0.49131571143033 |
| 2 | 5 | 57 | 8 | F | 0 | 7.125 | 0.83931571143033 |
| 2 | 5 | 58 | 6 | F | -3 | 6.285 | -6.84288569670066E-4 |
| 2 | 5 | 59 | 8 | M | -4 | 7.25 | 0.96431571143033 |
| 2 | 5 | 60 | 2 | M | -5 | 5.25 | -1.03568428856967 |
| 2 | 5 | 61 | 8 | F | 4 | 5.8 | -0.48568428856967 |
| 2 | 5 | 62 | 6 | F | 5 | 6 | -0.28568428856967 |
| 2 | 5 | 63 | 4 | F | -1 | 5.75 | -0.53568428856967 |
| 2 | 5 | 64 | 8 | M | 4 | 6.875 | 0.58931571143033 |
| 2 | 5 | 65 | 6 | M | 5 | 5.75 | -0.53568428856967 |
| 2 | 5 | 66 | 2 | M | -3 | 5.142 | -1.14368428856967 |
| 2 | 5 | 67 | 6 | F | 2 | 7.125 | 0.83931571143033 |
| 2 | 6 | 68 | 10 | F | 2 | 8 | 1.71431571143033 |
| 2 | 6 | 69 | 4 | F | 0 | 7 | 0.71431571143033 |
| 2 | 6 | 70 | 4 | F | 3 | 5.777 | -0.50868428856967 |
| 2 | 6 | 71 | 2 | F | -2 | 7 | 0.71431571143033 |
| 2 | 6 | 72 | 2 | F | -1 | 5.666 | -0.61968428856967 |
| 2 | 6 | 73 | 2 | M | 0 | 6.5 | 0.21431571143033 |
| 2 | 6 | 74 | 10 | F | 1 | 7.875 | 1.58931571143033 |
| 2 | 6 | 75 | 10 | F | -5 | 7.666 | 1.38031571143033 |
| 2 | 6 | 76 | 0 | M | 1 | 6.888 | 0.60231571143033 |
| 2 | 6 | 77 | 8 | F | 0 | 6.555 | 0.26931571143033 |
| 2 | 6 | 78 | 0 | F | 2 | 5.666 | -0.61968428856967 |
| 2 | 6 | 79 | 8 | M | 0 | 6.5 | 0.21431571143033 |
| 2 | 6 | 80 | 2 | F | -4 | 5.777 | -0.50868428856967 |
| 2 | 6 | 81 | 4 | F | 4 | 7 | 0.71431571143033 |
| 2 | 7 | 82 | 4 | F | -5 | 5.2 | -1.08568428856967 |
| 2 | 7 | 83 | 0 | F | -3 | 5 | -1.28568428856967 |
| 2 | 7 | 84 | 4 | F | 5 | 6.777 | 0.49131571143033 |
| 2 | 7 | 85 | 0 | F | 1 | 4.555 | -1.73068428856967 |
| 2 | 8 | 86 | 10 | F | 0 | 7.111 | 0.82531571143033 |
| 2 | 8 | 87 | 4 | M | -1 | 5.285 | -1.00068428856967 |
| 2 | 8 | 88 | 8 | F | -6 | 7 | 0.71431571143033 |
| 2 | 8 | 89 | 6 | M | 0 | 5.8 | -0.48568428856967 |
| 2 | 8 | 90 | 10 | F | 2 | 7.111 | 0.82531571143033 |
| 2 | 8 | 91 | 8 | F | -3 | 5.555 | -0.73068428856967 |
| 2 | 8 | 92 | 6 | F | -2 | 5.6 | -0.685684288569671 |
| 2 | 8 | 93 | 4 | M | 5 | 5.714 | -0.57168428856967 |
| 2 | 8 | 94 | 8 | F | -3 | 6.875 | 0.58931571143033 |
| 2 | 8 | 95 | 8 | M | 5 | 5 | -1.28568428856967 |
| 2 | 8 | 96 | 6 | F | -1 | 6.375 | 0.0893157114303298 |
| 2 | 9 | 97 | 10 | M | -2 | 6.875 | 0.58931571143033 |
| 2 | 9 | 98 | 6 | M | -1 | 5.875 | -0.41068428856967 |
| 2 | 9 | 99 | 10 | M | -5 | 8 | 1.71431571143033 |
| 2 | 9 | 100 | 10 | F | 2 | 6.625 | 0.33931571143033 |
| … | … | … | … | … | … | … | … |
(def oats (nu/dataset :oats))| block | variety | nitro | yield |
|---|---|---|---|
| I | Victory | 0 | 111 |
| I | Victory | 0.2 | 130 |
| I | Victory | 0.4 | 157 |
| I | Victory | 0.6 | 174 |
| I | Golden Rain | 0 | 117 |
| I | Golden Rain | 0.2 | 114 |
| I | Golden Rain | 0.4 | 161 |
| I | Golden Rain | 0.6 | 141 |
| I | Marvellous | 0 | 105 |
| I | Marvellous | 0.2 | 140 |
| I | Marvellous | 0.4 | 118 |
| I | Marvellous | 0.6 | 156 |
| II | Victory | 0 | 61 |
| II | Victory | 0.2 | 91 |
| II | Victory | 0.4 | 97 |
| II | Victory | 0.6 | 100 |
| II | Golden Rain | 0 | 70 |
| II | Golden Rain | 0.2 | 108 |
| II | Golden Rain | 0.4 | 126 |
| II | Golden Rain | 0.6 | 149 |
| II | Marvellous | 0 | 96 |
| II | Marvellous | 0.2 | 124 |
| II | Marvellous | 0.4 | 121 |
| II | Marvellous | 0.6 | 144 |
| III | Victory | 0 | 68 |
| III | Victory | 0.2 | 64 |
| III | Victory | 0.4 | 112 |
| III | Victory | 0.6 | 86 |
| III | Golden Rain | 0 | 60 |
| III | Golden Rain | 0.2 | 102 |
| III | Golden Rain | 0.4 | 89 |
| III | Golden Rain | 0.6 | 96 |
| III | Marvellous | 0 | 89 |
| III | Marvellous | 0.2 | 129 |
| III | Marvellous | 0.4 | 132 |
| III | Marvellous | 0.6 | 124 |
| IV | Victory | 0 | 74 |
| IV | Victory | 0.2 | 89 |
| IV | Victory | 0.4 | 81 |
| IV | Victory | 0.6 | 122 |
| IV | Golden Rain | 0 | 64 |
| IV | Golden Rain | 0.2 | 103 |
| IV | Golden Rain | 0.4 | 132 |
| IV | Golden Rain | 0.6 | 133 |
| IV | Marvellous | 0 | 70 |
| IV | Marvellous | 0.2 | 89 |
| IV | Marvellous | 0.4 | 104 |
| IV | Marvellous | 0.6 | 117 |
| V | Victory | 0 | 62 |
| V | Victory | 0.2 | 90 |
| V | Victory | 0.4 | 100 |
| V | Victory | 0.6 | 116 |
| V | Golden Rain | 0 | 80 |
| V | Golden Rain | 0.2 | 82 |
| V | Golden Rain | 0.4 | 94 |
| V | Golden Rain | 0.6 | 126 |
| V | Marvellous | 0 | 63 |
| V | Marvellous | 0.2 | 70 |
| V | Marvellous | 0.4 | 109 |
| V | Marvellous | 0.6 | 99 |
| VI | Victory | 0 | 53 |
| VI | Victory | 0.2 | 74 |
| VI | Victory | 0.4 | 118 |
| VI | Victory | 0.6 | 113 |
| VI | Golden Rain | 0 | 89 |
| VI | Golden Rain | 0.2 | 82 |
| VI | Golden Rain | 0.4 | 86 |
| VI | Golden Rain | 0.6 | 104 |
| VI | Marvellous | 0 | 97 |
| VI | Marvellous | 0.2 | 99 |
| VI | Marvellous | 0.4 | 119 |
| VI | Marvellous | 0.6 | 121 |
(def barley (nu/dataset :barley))| yield | variety | year | site |
|---|---|---|---|
| 27 | Manchuria | 1931 | University Farm |
| 48.86667 | Manchuria | 1931 | Waseca |
| 27.43334 | Manchuria | 1931 | Morris |
| 39.93333 | Manchuria | 1931 | Crookston |
| 32.96667 | Manchuria | 1931 | Grand Rapids |
| 28.96667 | Manchuria | 1931 | Duluth |
| 43.06666 | Glabron | 1931 | University Farm |
| 55.2 | Glabron | 1931 | Waseca |
| 28.76667 | Glabron | 1931 | Morris |
| 38.13333 | Glabron | 1931 | Crookston |
| 29.13333 | Glabron | 1931 | Grand Rapids |
| 29.66667 | Glabron | 1931 | Duluth |
| 35.13333 | Svansota | 1931 | University Farm |
| 47.33333 | Svansota | 1931 | Waseca |
| 25.76667 | Svansota | 1931 | Morris |
| 40.46667 | Svansota | 1931 | Crookston |
| 29.66667 | Svansota | 1931 | Grand Rapids |
| 25.7 | Svansota | 1931 | Duluth |
| 39.9 | Velvet | 1931 | University Farm |
| 50.23333 | Velvet | 1931 | Waseca |
| 26.13333 | Velvet | 1931 | Morris |
| 41.33333 | Velvet | 1931 | Crookston |
| 23.03333 | Velvet | 1931 | Grand Rapids |
| 26.3 | Velvet | 1931 | Duluth |
| 36.56666 | Trebi | 1931 | University Farm |
| 63.8333 | Trebi | 1931 | Waseca |
| 43.76667 | Trebi | 1931 | Morris |
| 46.93333 | Trebi | 1931 | Crookston |
| 29.76667 | Trebi | 1931 | Grand Rapids |
| 33.93333 | Trebi | 1931 | Duluth |
| 43.26667 | No. 457 | 1931 | University Farm |
| 58.1 | No. 457 | 1931 | Waseca |
| 28.7 | No. 457 | 1931 | Morris |
| 45.66667 | No. 457 | 1931 | Crookston |
| 32.16667 | No. 457 | 1931 | Grand Rapids |
| 33.6 | No. 457 | 1931 | Duluth |
| 36.6 | No. 462 | 1931 | University Farm |
| 65.7667 | No. 462 | 1931 | Waseca |
| 30.36667 | No. 462 | 1931 | Morris |
| 48.56666 | No. 462 | 1931 | Crookston |
| 24.93334 | No. 462 | 1931 | Grand Rapids |
| 28.1 | No. 462 | 1931 | Duluth |
| 32.76667 | Peatland | 1931 | University Farm |
| 48.56666 | Peatland | 1931 | Waseca |
| 29.86667 | Peatland | 1931 | Morris |
| 41.6 | Peatland | 1931 | Crookston |
| 34.7 | Peatland | 1931 | Grand Rapids |
| 32 | Peatland | 1931 | Duluth |
| 24.66667 | No. 475 | 1931 | University Farm |
| 46.76667 | No. 475 | 1931 | Waseca |
| 22.6 | No. 475 | 1931 | Morris |
| 44.1 | No. 475 | 1931 | Crookston |
| 19.7 | No. 475 | 1931 | Grand Rapids |
| 33.06666 | No. 475 | 1931 | Duluth |
| 39.3 | Wisconsin No. 38 | 1931 | University Farm |
| 58.8 | Wisconsin No. 38 | 1931 | Waseca |
| 29.46667 | Wisconsin No. 38 | 1931 | Morris |
| 49.86667 | Wisconsin No. 38 | 1931 | Crookston |
| 34.46667 | Wisconsin No. 38 | 1931 | Grand Rapids |
| 31.6 | Wisconsin No. 38 | 1931 | Duluth |
| 26.9 | Manchuria | 1932 | University Farm |
| 33.46667 | Manchuria | 1932 | Waseca |
| 34.36666 | Manchuria | 1932 | Morris |
| 32.96667 | Manchuria | 1932 | Crookston |
| 22.13333 | Manchuria | 1932 | Grand Rapids |
| 22.56667 | Manchuria | 1932 | Duluth |
| 36.8 | Glabron | 1932 | University Farm |
| 37.73333 | Glabron | 1932 | Waseca |
| 35.13333 | Glabron | 1932 | Morris |
| 26.16667 | Glabron | 1932 | Crookston |
| 14.43333 | Glabron | 1932 | Grand Rapids |
| 25.86667 | Glabron | 1932 | Duluth |
| 27.43334 | Svansota | 1932 | University Farm |
| 38.5 | Svansota | 1932 | Waseca |
| 35.03333 | Svansota | 1932 | Morris |
| 20.63333 | Svansota | 1932 | Crookston |
| 16.63333 | Svansota | 1932 | Grand Rapids |
| 22.23333 | Svansota | 1932 | Duluth |
| 26.8 | Velvet | 1932 | University Farm |
| 37.4 | Velvet | 1932 | Waseca |
| 38.83333 | Velvet | 1932 | Morris |
| 32.06666 | Velvet | 1932 | Crookston |
| 32.23333 | Velvet | 1932 | Grand Rapids |
| 22.46667 | Velvet | 1932 | Duluth |
| 29.06667 | Trebi | 1932 | University Farm |
| 49.2333 | Trebi | 1932 | Waseca |
| 46.63333 | Trebi | 1932 | Morris |
| 41.83333 | Trebi | 1932 | Crookston |
| 20.63333 | Trebi | 1932 | Grand Rapids |
| 30.6 | Trebi | 1932 | Duluth |
| 26.43334 | No. 457 | 1932 | University Farm |
| 42.2 | No. 457 | 1932 | Waseca |
| 43.53334 | No. 457 | 1932 | Morris |
| 34.33333 | No. 457 | 1932 | Crookston |
| 19.46667 | No. 457 | 1932 | Grand Rapids |
| 22.7 | No. 457 | 1932 | Duluth |
| 25.56667 | No. 462 | 1932 | University Farm |
| 44.7 | No. 462 | 1932 | Waseca |
| 47 | No. 462 | 1932 | Morris |
| 30.53333 | No. 462 | 1932 | Crookston |
| … | … | … | … |
(def titanic (nu/dataset :titanic))| class | sex | age | survived | n |
|---|---|---|---|---|
| 1st | Male | Child | No | 0 |
| 2nd | Male | Child | No | 0 |
| 3rd | Male | Child | No | 35 |
| Crew | Male | Child | No | 0 |
| 1st | Female | Child | No | 0 |
| 2nd | Female | Child | No | 0 |
| 3rd | Female | Child | No | 17 |
| Crew | Female | Child | No | 0 |
| 1st | Male | Adult | No | 118 |
| 2nd | Male | Adult | No | 154 |
| 3rd | Male | Adult | No | 387 |
| Crew | Male | Adult | No | 670 |
| 1st | Female | Adult | No | 4 |
| 2nd | Female | Adult | No | 13 |
| 3rd | Female | Adult | No | 89 |
| Crew | Female | Adult | No | 3 |
| 1st | Male | Child | Yes | 5 |
| 2nd | Male | Child | Yes | 11 |
| 3rd | Male | Child | Yes | 13 |
| Crew | Male | Child | Yes | 0 |
| 1st | Female | Child | Yes | 1 |
| 2nd | Female | Child | Yes | 13 |
| 3rd | Female | Child | Yes | 14 |
| Crew | Female | Child | Yes | 0 |
| 1st | Male | Adult | Yes | 57 |
| 2nd | Male | Adult | Yes | 14 |
| 3rd | Male | Adult | Yes | 75 |
| Crew | Male | Adult | Yes | 192 |
| 1st | Female | Adult | Yes | 140 |
| 2nd | Female | Adult | Yes | 80 |
| 3rd | Female | Adult | Yes | 76 |
| Crew | Female | Adult | Yes | 20 |
(def faithful (nu/dataset :faithful))| eruptions | waiting |
|---|---|
| 3.6 | 79 |
| 1.8 | 54 |
| 3.333 | 74 |
| 2.283 | 62 |
| 4.533 | 85 |
| 2.883 | 55 |
| 4.7 | 88 |
| 3.6 | 85 |
| 1.95 | 51 |
| 4.35 | 85 |
| 1.833 | 54 |
| 3.917 | 84 |
| 4.2 | 78 |
| 1.75 | 47 |
| 4.7 | 83 |
| 2.167 | 52 |
| 1.75 | 62 |
| 4.8 | 84 |
| 1.6 | 52 |
| 4.25 | 79 |
| 1.8 | 51 |
| 1.75 | 47 |
| 3.45 | 78 |
| 3.067 | 69 |
| 4.533 | 74 |
| 3.6 | 83 |
| 1.967 | 55 |
| 4.083 | 76 |
| 3.85 | 78 |
| 4.433 | 79 |
| 4.3 | 73 |
| 4.467 | 77 |
| 3.367 | 66 |
| 4.033 | 80 |
| 3.833 | 74 |
| 2.017 | 52 |
| 1.867 | 48 |
| 4.833 | 80 |
| 1.833 | 59 |
| 4.783 | 90 |
| 4.35 | 80 |
| 1.883 | 58 |
| 4.567 | 84 |
| 1.75 | 58 |
| 4.533 | 73 |
| 3.317 | 83 |
| 3.833 | 64 |
| 2.1 | 53 |
| 4.633 | 82 |
| 2 | 59 |
| 4.8 | 75 |
| 4.716 | 90 |
| 1.833 | 54 |
| 4.833 | 80 |
| 1.733 | 54 |
| 4.883 | 83 |
| 3.717 | 71 |
| 1.667 | 64 |
| 4.567 | 77 |
| 4.317 | 81 |
| 2.233 | 59 |
| 4.5 | 84 |
| 1.75 | 48 |
| 4.8 | 82 |
| 1.817 | 60 |
| 4.4 | 92 |
| 4.167 | 78 |
| 4.7 | 78 |
| 2.067 | 65 |
| 4.7 | 73 |
| 4.033 | 82 |
| 1.967 | 56 |
| 4.5 | 79 |
| 4 | 71 |
| 1.983 | 62 |
| 5.067 | 76 |
| 2.017 | 60 |
| 4.567 | 78 |
| 3.883 | 76 |
| 3.6 | 83 |
| 4.133 | 75 |
| 4.333 | 82 |
| 4.1 | 70 |
| 2.633 | 65 |
| 4.067 | 73 |
| 4.933 | 88 |
| 3.95 | 76 |
| 4.517 | 80 |
| 2.167 | 48 |
| 4 | 86 |
| 2.2 | 60 |
| 4.333 | 90 |
| 1.867 | 50 |
| 4.817 | 78 |
| 1.833 | 63 |
| 4.3 | 72 |
| 4.667 | 84 |
| 3.75 | 75 |
| 1.867 | 51 |
| 4.9 | 82 |
| … | … |
(def gvhd10 (nu/dataset :gvhd10))| fsc-h | ssc-h | fl1-h | fl2-h | fl3-h | fl2-a | fl4-h | days |
|---|---|---|---|---|---|---|---|
| 548 | 536 | 1 | 20.0471567388252 | 1 | 8 | 2.09230797761688 | -6 |
| 213 | 33 | 2.13032443014118 | 104.134661084393 | 7.93077699270318 | 23 | 1 | -6 |
| 205 | 38 | 4.11036835059307 | 141.428727684403 | 5.94557070854439 | 30 | 1 | -6 |
| 119 | 45 | 1.55450940125585 | 630.389532491958 | 4.79018080525539 | 148 | 1.2637517764381 | -6 |
| 474 | 904 | 170.863410719865 | 2203.47691230698 | 84.6571676104789 | 812 | 37.9898557212078 | -6 |
| 198 | 45 | 1.48608281057475 | 136.4260674966 | 1 | 28 | 1.94690635864944 | -6 |
| 267 | 177 | 64.6192155154038 | 132.790545637149 | 17.8328968037465 | 29 | 7.05480231071864 | -6 |
| 60 | 82 | 3.10934291996487 | 320.888284294226 | 1 | 105 | 1.65563207635131 | -6 |
| 69 | 8 | 1 | 30.8841796746407 | 1 | 12 | 2.14959090655457 | -6 |
| 552 | 544 | 1.05550528101563 | 18.6540114290992 | 1 | 5 | 1.96451401732681 | -6 |
| 619 | 466 | 2.62045871358794 | 12.6659945315439 | 1 | 65 | 1.00904391657007 | -6 |
| 143 | 388 | 1 | 108.929535084032 | 1 | 54 | 1.38280984651361 | -6 |
| 250 | 719 | 1.45956309563553 | 20.4114060704541 | 1 | 10 | 1 | -6 |
| 453 | 645 | 1 | 14.1110755578985 | 1.70095975066655 | 4 | 1.73186555244082 | -6 |
| 93 | 68 | 1.76333290106119 | 11.6801569979431 | 1.91216307161501 | 65 | 1 | -6 |
| 423 | 476 | 251.641354213874 | 1942.52915803364 | 46.7303698178921 | 469 | 84.6571676104789 | -6 |
| 314 | 447 | 280.351468174132 | 1072.26722201032 | 44.6733865115693 | 246 | 62.8972237079901 | -6 |
| 149 | 190 | 33.4908898004629 | 188.65130945543 | 12.6659945315439 | 42 | 7.4463810954848 | -6 |
| 192 | 46 | 2.43835409826883 | 288.026893303126 | 1.98228091820025 | 65 | 2.57369562770885 | -6 |
| 221 | 82 | 1.87803979179797 | 125.807561577878 | 1.29835060413413 | 26 | 1.37041591927341 | -6 |
| 111 | 94 | 7.18298542715413 | 90.9796541404939 | 2.24856868629063 | 20 | 3.08147432327237 | -6 |
| 73 | 119 | 44.2729853259731 | 197.33774727821 | 6.74426313375284 | 48 | 7.71943532136078 | -6 |
| 150 | 183 | 30.0611689965592 | 229.9753716788 | 8.37097699835546 | 52 | 6.27558128152045 | -6 |
| 223 | 340 | 2263.80340952145 | 1111.58660312765 | 22.134185158215 | 278 | 23.5740400812209 | -6 |
| 107 | 147 | 236.271606752329 | 728.064889525607 | 17.2021061268172 | 185 | 70.7069925872126 | -6 |
| 303 | 212 | 715.072293695766 | 526.511212920003 | 88.5552016332685 | 122 | 60.1286057902297 | -6 |
| 183 | 31 | 1.79537199962357 | 363.994498073774 | 2.94583359826773 | 83 | 1.14459284406143 | -6 |
| 126 | 156 | 166.310192437971 | 1025.06802833418 | 51.5952796467086 | 241 | 41.5688804861519 | -6 |
| 92 | 215 | 35.6695117922078 | 117.064764949724 | 16.5936279705333 | 39 | 7.31349758281927 | -6 |
| 120 | 177 | 192.079033110973 | 1238.40907295655 | 20.0471567388252 | 293 | 37.3119122464974 | -6 |
| 100 | 180 | 22.3343648821325 | 472.592476475583 | 11.7857913633579 | 142 | 21.1598798071781 | -6 |
| 174 | 1023 | 9.15960684216839 | 6.05359950210121 | 5.63291422173031 | 0 | 3.52703345957657 | -6 |
| 284 | 98 | 17.8328968037465 | 142.707797298193 | 1 | 31 | 49.3241521265985 | -6 |
| 149 | 42 | 1 | 270.434790343611 | 1.96451401732681 | 62 | 1 | -6 |
| 684 | 781 | 199.12245340072 | 2106.48398795936 | 401.888493311026 | 520 | 119.191787895958 | -6 |
| 201 | 274 | 59.5896816806725 | 754.762582303841 | 14.8943147721724 | 178 | 5.68385782799802 | -6 |
| 166 | 73 | 3.55893165592484 | 277.838717988706 | 1 | 62 | 1.40793498365523 | -6 |
| 147 | 178 | 32.3062398088944 | 124.679966364121 | 10.3900536674351 | 28 | 6.21933414241503 | -6 |
| 263 | 68 | 5.24146379659874 | 106.02674888485 | 1 | 22 | 1 | -6 |
| 109 | 220 | 39.3829204209698 | 256.213583397131 | 9.93270297603253 | 60 | 8.75641811414753 | -6 |
| 89 | 147 | 30.333039700963 | 185.284754836759 | 6.80525768686113 | 41 | 7.4463810954848 | -6 |
| 184 | 56 | 3.49542116220829 | 69.4451993181706 | 1.37041591927341 | 12 | 1.64079288241399 | -6 |
| 424 | 479 | 60.1286057902297 | 818.466630350764 | 34.0994067280454 | 202 | 13.1304487795084 | -6 |
| 176 | 327 | 26.2636352765333 | 290.631784496097 | 12.4399650249727 | 67 | 4.33851550097049 | -6 |
| 166 | 210 | 56.9666555645962 | 428.031815121024 | 12.3284673944207 | 102 | 7.24794774808137 | -6 |
| 117 | 36 | 3.43304403749179 | 133.991492253186 | 1 | 28 | 1.40793498365523 | -6 |
| 69 | 144 | 19.8674769349675 | 129.251904230482 | 8.91551895259033 | 41 | 3.59111833689962 | -6 |
| 149 | 320 | 2809.83198521168 | 536.077724515626 | 19.6894075755402 | 137 | 40.8270679485257 | -6 |
| 752 | 610 | 251.641354213874 | 1840.37843578054 | 447.740513454224 | 466 | 149.278768958209 | -6 |
| 442 | 499 | 373.95989092699 | 531.27293640286 | 146.614832351797 | 145 | 43.8761728790409 | -6 |
| 96 | 168 | 21.739192176242 | 173.967934915758 | 10.2046391942289 | 43 | 5.19448530487696 | -6 |
| 209 | 46 | 1.79537199962357 | 424.195427069203 | 2.20844211988575 | 98 | 1.37041591927341 | -6 |
| 214 | 50 | 3.59111833689962 | 130.420847668866 | 3.52703345957657 | 27 | 1.15494444624982 | -6 |
| 733 | 407 | 1283.82077380798 | 1034.33865806109 | 223.846920524153 | 247 | 167.814287943133 | -6 |
| 201 | 34 | 1.79537199962357 | 304.013906955975 | 4.00083404924448 | 68 | 1.35813307703366 | -6 |
| 97 | 125 | 11.0659389469887 | 108.929535084032 | 6.50570299658905 | 25 | 2.79092265216635 | -6 |
| 376 | 332 | 136.4260674966 | 734.649447644077 | 229.9753716788 | 173 | 62.8972237079901 | -6 |
| 214 | 72 | 2.66807146722781 | 48.4439438066395 | 3.13746355792078 | 8 | 1.98228091820025 | -6 |
| 135 | 175 | 73.2997746215121 | 260.868888272656 | 14.1110755578985 | 66 | 9.75545010046874 | -6 |
| 391 | 226 | 70.7069925872126 | 489.922152618146 | 14.1110755578985 | 145 | 22.5363550147721 | -6 |
| 74 | 113 | 26.7408356955381 | 145.300744540603 | 3.16583851658026 | 36 | 4.87721659688546 | -6 |
| 298 | 72 | 8.52307451604617 | 439.750413105138 | 1.17592935438895 | 104 | 2.18864816844905 | -6 |
| 227 | 63 | 4.2610930359999 | 87.7614940034364 | 1.79537199962357 | 17 | 1.10410595610039 | -6 |
| 193 | 79 | 12.3284673944207 | 48.4439438066395 | 8.22159371891811 | 11 | 1.86120718925869 | -6 |
| 109 | 197 | 265.608778294669 | 1238.40907295655 | 22.9458321470371 | 303 | 58.5262810678365 | -6 |
| 90 | 51 | 1.3338966739233 | 163.34232357928 | 1.09421001204135 | 38 | 1 | -6 |
| 379 | 288 | 60.6724038844714 | 555.735365751008 | 227.914135254419 | 130 | 63.4660609516945 | -6 |
| 66 | 167 | 12.6659945315439 | 142.707797298193 | 10.2046391942289 | 80 | 3.37178005637296 | -6 |
| 250 | 482 | 7842.02373630883 | 526.511212920003 | 1.59706855245047 | 115 | 12.3284673944207 | -6 |
| 105 | 127 | 20.4114060704541 | 151.991108295293 | 8.4466834159386 | 34 | 3.40227415389544 | -6 |
| 116 | 199 | 145.300744540603 | 111.911793376878 | 10.7710505603677 | 26 | 11.0659389469887 | -6 |
| 95 | 109 | 12.6659945315439 | 138.904878060602 | 9.24244556226364 | 32 | 4.49760620239682 | -6 |
| 190 | 380 | 3394.6248715068 | 1823.88338659859 | 21.1598798071781 | 484 | 64.6192155154038 | -6 |
| 206 | 52 | 2.35210389174505 | 238.408427451674 | 1.19729555045153 | 53 | 1.05550528101563 | -6 |
| 221 | 416 | 6609.01674756612 | 945.283489164419 | 24.4384856666141 | 228 | 60.1286057902297 | -6 |
| 273 | 145 | 60.6724038844714 | 221.840612532554 | 92.6327203904486 | 50 | 65.2036263093488 | -6 |
| 122 | 192 | 82.4011985786459 | 443.727479152916 | 8.91551895259033 | 111 | 46.3115321845825 | -6 |
| 101 | 184 | 1152.34780182525 | 1111.58660312765 | 26.2636352765333 | 275 | 26.2636352765333 | -6 |
| 249 | 89 | 2.16903162737324 | 586.581613397342 | 1.13433402180562 | 138 | 1.65563207635131 | -6 |
| 215 | 57 | 2.69220128298041 | 124.679966364121 | 3.40227415389544 | 26 | 1 | -6 |
| 429 | 400 | 84.6571676104789 | 526.511212920003 | 217.881782133305 | 152 | 46.7303698178921 | -6 |
| 375 | 392 | 351.119173421513 | 503.335176013196 | 151.991108295293 | 119 | 68.8227719108873 | -6 |
| 132 | 326 | 3187.28801638324 | 143.998434710856 | 1.32194114846603 | 28 | 10.2046391942289 | -6 |
| 202 | 39 | 3.43304403749179 | 158.98952943339 | 4.49760620239682 | 34 | 1 | -6 |
| 236 | 286 | 167.814287943133 | 1205.40758476377 | 47.5794431400941 | 304 | 30.8841796746407 | -6 |
| 396 | 208 | 27.9721158137042 | 920.093297500199 | 247.150718205448 | 225 | 70.7069925872126 | -6 |
| 213 | 53 | 2.94583359826773 | 135.203300130224 | 1 | 28 | 1.37041591927341 | -6 |
| 212 | 347 | 65.7933224657568 | 351.119173421513 | 13.9846000022126 | 84 | 4.83350280081368 | -6 |
| 181 | 354 | 2346.81569154085 | 734.649447644077 | 8.00250227816105 | 188 | 84.6571676104789 | -6 |
| 187 | 66 | 5.68385782799802 | 424.195427069203 | 1.28671367302571 | 99 | 1 | -6 |
| 587 | 494 | 268.010921925845 | 1593.47788697228 | 238.408427451674 | 373 | 86.9749002617783 | -6 |
| 84 | 136 | 33.7937786136758 | 130.420847668866 | 8.99615016217647 | 31 | 5.43366505800142 | -6 |
| 133 | 75 | 2.09230797761688 | 1430.29368099655 | 6.33233711505923 | 343 | 1.12416714790911 | -6 |
| 339 | 251 | 122.455004778482 | 928.414544519474 | 219.852286793058 | 213 | 71.9917121674961 | -6 |
| 212 | 61 | 3.75647115760237 | 36.64606693184 | 2.22841508616783 | 5 | 1.28671367302571 | -6 |
| 358 | 371 | 104.134661084393 | 833.337862563382 | 208.291034395878 | 198 | 57.4818572447986 | -6 |
| 68 | 153 | 111.911793376878 | 160.427417473101 | 13.9846000022126 | 40 | 16.1514361055807 | -6 |
| 195 | 155 | 39.0299369276608 | 192.079033110973 | 99.5508484525876 | 41 | 47.5794431400941 | -6 |
| 356 | 172 | 183.624074030966 | 576.113840629102 | 158.98952943339 | 133 | 56.9666555645962 | -6 |
| 240 | 384 | 56.4560715635018 | 394.716639761467 | 23.1533523386059 | 100 | 9.41037733745403 | -6 |
| … | … | … | … | … | … | … | … |
(def quakes (nu/dataset :quakes))| lat | long | depth | mag | stations |
|---|---|---|---|---|
| -20.42 | 181.62 | 562 | 4.8 | 41 |
| -20.62 | 181.03 | 650 | 4.2 | 15 |
| -26 | 184.1 | 42 | 5.4 | 43 |
| -17.97 | 181.66 | 626 | 4.1 | 19 |
| -20.42 | 181.96 | 649 | 4 | 11 |
| -19.68 | 184.31 | 195 | 4 | 12 |
| -11.7 | 166.1 | 82 | 4.8 | 43 |
| -28.11 | 181.93 | 194 | 4.4 | 15 |
| -28.74 | 181.74 | 211 | 4.7 | 35 |
| -17.47 | 179.59 | 622 | 4.3 | 19 |
| -21.44 | 180.69 | 583 | 4.4 | 13 |
| -12.26 | 167 | 249 | 4.6 | 16 |
| -18.54 | 182.11 | 554 | 4.4 | 19 |
| -21 | 181.66 | 600 | 4.4 | 10 |
| -20.7 | 169.92 | 139 | 6.1 | 94 |
| -15.94 | 184.95 | 306 | 4.3 | 11 |
| -13.64 | 165.96 | 50 | 6 | 83 |
| -17.83 | 181.5 | 590 | 4.5 | 21 |
| -23.5 | 179.78 | 570 | 4.4 | 13 |
| -22.63 | 180.31 | 598 | 4.4 | 18 |
| -20.84 | 181.16 | 576 | 4.5 | 17 |
| -10.98 | 166.32 | 211 | 4.2 | 12 |
| -23.3 | 180.16 | 512 | 4.4 | 18 |
| -30.2 | 182 | 125 | 4.7 | 22 |
| -19.66 | 180.28 | 431 | 5.4 | 57 |
| -17.94 | 181.49 | 537 | 4 | 15 |
| -14.72 | 167.51 | 155 | 4.6 | 18 |
| -16.46 | 180.79 | 498 | 5.2 | 79 |
| -20.97 | 181.47 | 582 | 4.5 | 25 |
| -19.84 | 182.37 | 328 | 4.4 | 17 |
| -22.58 | 179.24 | 553 | 4.6 | 21 |
| -16.32 | 166.74 | 50 | 4.7 | 30 |
| -15.55 | 185.05 | 292 | 4.8 | 42 |
| -23.55 | 180.8 | 349 | 4 | 10 |
| -16.3 | 186 | 48 | 4.5 | 10 |
| -25.82 | 179.33 | 600 | 4.3 | 13 |
| -18.73 | 169.23 | 206 | 4.5 | 17 |
| -17.64 | 181.28 | 574 | 4.6 | 17 |
| -17.66 | 181.4 | 585 | 4.1 | 17 |
| -18.82 | 169.33 | 230 | 4.4 | 11 |
| -37.37 | 176.78 | 263 | 4.7 | 34 |
| -15.31 | 186.1 | 96 | 4.6 | 32 |
| -24.97 | 179.82 | 511 | 4.4 | 23 |
| -15.49 | 186.04 | 94 | 4.3 | 26 |
| -19.23 | 169.41 | 246 | 4.6 | 27 |
| -30.1 | 182.3 | 56 | 4.9 | 34 |
| -26.4 | 181.7 | 329 | 4.5 | 24 |
| -11.77 | 166.32 | 70 | 4.4 | 18 |
| -24.12 | 180.08 | 493 | 4.3 | 21 |
| -18.97 | 185.25 | 129 | 5.1 | 73 |
| -18.75 | 182.35 | 554 | 4.2 | 13 |
| -19.26 | 184.42 | 223 | 4 | 15 |
| -22.75 | 173.2 | 46 | 4.6 | 26 |
| -21.37 | 180.67 | 593 | 4.3 | 13 |
| -20.1 | 182.16 | 489 | 4.2 | 16 |
| -19.85 | 182.13 | 562 | 4.4 | 31 |
| -22.7 | 181 | 445 | 4.5 | 17 |
| -22.06 | 180.6 | 584 | 4 | 11 |
| -17.8 | 181.35 | 535 | 4.4 | 23 |
| -24.2 | 179.2 | 530 | 4.3 | 12 |
| -20.69 | 181.55 | 582 | 4.7 | 35 |
| -21.16 | 182.4 | 260 | 4.1 | 12 |
| -13.82 | 172.38 | 613 | 5 | 61 |
| -11.49 | 166.22 | 84 | 4.6 | 32 |
| -20.68 | 181.41 | 593 | 4.9 | 40 |
| -17.1 | 184.93 | 286 | 4.7 | 25 |
| -20.14 | 181.6 | 587 | 4.1 | 13 |
| -21.96 | 179.62 | 627 | 5 | 45 |
| -20.42 | 181.86 | 530 | 4.5 | 27 |
| -15.46 | 187.81 | 40 | 5.5 | 91 |
| -15.31 | 185.8 | 152 | 4 | 11 |
| -19.86 | 184.35 | 201 | 4.5 | 30 |
| -11.55 | 166.2 | 96 | 4.3 | 14 |
| -23.74 | 179.99 | 506 | 5.2 | 75 |
| -17.7 | 181.23 | 546 | 4.4 | 35 |
| -23.54 | 180.04 | 564 | 4.3 | 15 |
| -19.21 | 184.7 | 197 | 4.1 | 11 |
| -12.11 | 167.06 | 265 | 4.5 | 23 |
| -21.81 | 181.71 | 323 | 4.2 | 15 |
| -28.98 | 181.11 | 304 | 5.3 | 60 |
| -34.02 | 180.21 | 75 | 5.2 | 65 |
| -23.84 | 180.99 | 367 | 4.5 | 27 |
| -19.57 | 182.38 | 579 | 4.6 | 38 |
| -20.12 | 183.4 | 284 | 4.3 | 15 |
| -17.7 | 181.7 | 450 | 4 | 11 |
| -19.66 | 184.31 | 170 | 4.3 | 15 |
| -21.5 | 170.5 | 117 | 4.7 | 32 |
| -23.64 | 179.96 | 538 | 4.5 | 26 |
| -15.43 | 186.3 | 123 | 4.2 | 16 |
| -15.41 | 186.44 | 69 | 4.3 | 42 |
| -15.48 | 167.53 | 128 | 5.1 | 61 |
| -13.36 | 167.06 | 236 | 4.7 | 22 |
| -20.64 | 182.02 | 497 | 5.2 | 64 |
| -19.72 | 169.71 | 271 | 4.2 | 14 |
| -15.44 | 185.26 | 224 | 4.2 | 21 |
| -19.73 | 182.4 | 375 | 4 | 18 |
| -27.24 | 181.11 | 365 | 4.5 | 21 |
| -18.16 | 183.41 | 306 | 5.2 | 54 |
| -13.66 | 166.54 | 50 | 5.1 | 45 |
| -24.57 | 179.92 | 484 | 4.7 | 33 |
| … | … | … | … | … |
(def va-deaths (nu/dataset :va-deaths))| age | group | rate |
|---|---|---|
| 50-54 | Rural Male | 11.7 |
| 55-59 | Rural Male | 18.1 |
| 60-64 | Rural Male | 26.9 |
| 65-69 | Rural Male | 41 |
| 70-74 | Rural Male | 66 |
| 50-54 | Rural Female | 8.7 |
| 55-59 | Rural Female | 11.7 |
| 60-64 | Rural Female | 20.3 |
| 65-69 | Rural Female | 30.9 |
| 70-74 | Rural Female | 54.3 |
| 50-54 | Urban Male | 15.4 |
| 55-59 | Urban Male | 24.3 |
| 60-64 | Urban Male | 37 |
| 65-69 | Urban Male | 54.6 |
| 70-74 | Urban Male | 71.1 |
| 50-54 | Urban Female | 8.4 |
| 55-59 | Urban Female | 13.6 |
| 60-64 | Urban Female | 19.3 |
| 65-69 | Urban Female | 35.1 |
| 70-74 | Urban Female | 50 |
(def postdoc (nu/dataset :postdoc))| field | reason | count |
|---|---|---|
| Biological Sciences | Expected or Additional Training | 6404 |
| Chemistry | Expected or Additional Training | 865 |
| Earth, Atmospheric, and Ocean Sciences | Expected or Additional Training | 343 |
| Engineering | Expected or Additional Training | 586 |
| Medical Sciences | Expected or Additional Training | 205 |
| Physics and Astronomy | Expected or Additional Training | 1010 |
| Social and Behavioral Sciences | Expected or Additional Training | 1368 |
| All Postdoctorates | Expected or Additional Training | 11197 |
| Biological Sciences | Work with Specific Person | 2427 |
| Chemistry | Work with Specific Person | 308 |
| Earth, Atmospheric, and Ocean Sciences | Work with Specific Person | 75 |
| Engineering | Work with Specific Person | 464 |
| Medical Sciences | Work with Specific Person | 137 |
| Physics and Astronomy | Work with Specific Person | 347 |
| Social and Behavioral Sciences | Work with Specific Person | 564 |
| All Postdoctorates | Work with Specific Person | 4687 |
| Biological Sciences | Training Outside PhD Field | 1950 |
| Chemistry | Training Outside PhD Field | 292 |
| Earth, Atmospheric, and Ocean Sciences | Training Outside PhD Field | 75 |
| Engineering | Training Outside PhD Field | 288 |
| Medical Sciences | Training Outside PhD Field | 82 |
| Physics and Astronomy | Training Outside PhD Field | 175 |
| Social and Behavioral Sciences | Training Outside PhD Field | 412 |
| All Postdoctorates | Training Outside PhD Field | 3403 |
| Biological Sciences | Other Employment Not Available | 1779 |
| Chemistry | Other Employment Not Available | 551 |
| Earth, Atmospheric, and Ocean Sciences | Other Employment Not Available | 238 |
| Engineering | Other Employment Not Available | 517 |
| Medical Sciences | Other Employment Not Available | 68 |
| Physics and Astronomy | Other Employment Not Available | 399 |
| Social and Behavioral Sciences | Other Employment Not Available | 514 |
| All Postdoctorates | Other Employment Not Available | 4406 |
| Biological Sciences | Other | 602 |
| Chemistry | Other | 168 |
| Earth, Atmospheric, and Ocean Sciences | Other | 80 |
| Engineering | Other | 401 |
| Medical Sciences | Other | 74 |
| Physics and Astronomy | Other | 162 |
| Social and Behavioral Sciences | Other | 305 |
| All Postdoctorates | Other | 1914 |
(def earthquake (nu/dataset :earthquake))| quake | richter | distance | soil | accel |
|---|---|---|---|---|
| T | 5 | 7.5 | R | 0.264 |
| T | 5 | 8.8 | R | 0.263 |
| T | 5 | 8.9 | R | 0.23 |
| T | 5 | 9.4 | R | 0.147 |
| T | 5 | 9.7 | R | 0.286 |
| T | 5 | 9.7 | R | 0.157 |
| T | 5 | 10.5 | R | 0.237 |
| T | 5 | 10.5 | R | 0.133 |
| T | 5 | 12 | R | 0.055 |
| T | 5 | 12.2 | R | 0.097 |
| T | 5 | 12.8 | R | 0.129 |
| T | 5 | 14.6 | R | 0.192 |
| T | 5 | 14.9 | R | 0.147 |
| T | 5 | 17.6 | R | 0.154 |
| T | 5 | 23.9 | R | 0.06 |
| T | 5 | 25 | R | 0.057 |
| P | 5.1 | 2.9 | R | 0.21 |
| P | 5.1 | 3.2 | R | 0.39 |
| P | 5.1 | 7.6 | R | 0.28 |
| N | 5.2 | 17 | S | 0.011 |
| N | 5.2 | 8 | R | 0.12 |
| N | 5.2 | 10 | R | 0.17 |
| N | 5.2 | 10 | R | 0.14 |
| C | 5.3 | 8 | S | 0.127 |
| H | 5.3 | 19 | S | 0.086 |
| H | 5.3 | 21 | S | 0.179 |
| H | 5.3 | 13 | R | 0.205 |
| H | 5.3 | 22 | R | 0.073 |
| H | 5.3 | 29 | R | 0.045 |
| J | 5.3 | 31 | R | 0.03 |
| W | 5.3 | 5.8 | R | 0.123 |
| W | 5.3 | 12 | R | 0.133 |
| W | 5.3 | 12.1 | R | 0.073 |
| W | 5.3 | 20.5 | R | 0.097 |
| W | 5.3 | 20.5 | R | 0.096 |
| W | 5.3 | 25.3 | R | 0.23 |
| W | 5.3 | 35.9 | R | 0.082 |
| W | 5.3 | 36.1 | R | 0.11 |
| W | 5.3 | 36.3 | R | 0.11 |
| W | 5.3 | 38.5 | R | 0.094 |
| W | 5.3 | 41.4 | R | 0.04 |
| W | 5.3 | 43.6 | R | 0.05 |
| W | 5.3 | 44.4 | R | 0.022 |
| W | 5.3 | 46.1 | R | 0.07 |
| W | 5.3 | 47.1 | R | 0.08 |
| W | 5.3 | 47.7 | R | 0.033 |
| W | 5.3 | 49.2 | R | 0.017 |
| W | 5.3 | 53.1 | R | 0.022 |
| V | 5.5 | 4 | R | 0.259 |
| V | 5.5 | 10.1 | R | 0.267 |
| V | 5.5 | 11.1 | R | 0.071 |
| V | 5.5 | 17.7 | R | 0.275 |
| V | 5.5 | 22.5 | R | 0.058 |
| V | 5.5 | 26.5 | R | 0.026 |
| V | 5.5 | 29 | R | 0.039 |
| V | 5.5 | 30.9 | R | 0.112 |
| V | 5.5 | 37.8 | R | 0.065 |
| V | 5.5 | 48.3 | R | 0.026 |
| F | 5.6 | 62 | R | 0.005 |
| M | 5.6 | 50 | S | 0.031 |
| M | 5.6 | 16 | R | 0.13 |
| G | 5.7 | 62 | R | 0.003 |
| R | 5.8 | 1.2 | S | 0.42 |
| R | 5.8 | 1.6 | S | 0.23 |
| R | 5.8 | 9.1 | S | 0.13 |
| R | 5.8 | 3.7 | R | 0.26 |
| R | 5.8 | 5.3 | R | 0.27 |
| R | 5.8 | 7.4 | R | 0.26 |
| R | 5.8 | 17.9 | R | 0.11 |
| R | 5.8 | 19.2 | R | 0.12 |
| R | 5.8 | 23.4 | R | 0.038 |
| R | 5.8 | 30 | R | 0.044 |
| R | 5.8 | 38.9 | R | 0.046 |
| U | 5.8 | 10.8 | R | 0.12 |
| U | 5.8 | 15.7 | R | 0.154 |
| U | 5.8 | 16.7 | R | 0.052 |
| U | 5.8 | 20.8 | R | 0.045 |
| U | 5.8 | 28.5 | R | 0.086 |
| U | 5.8 | 33.1 | R | 0.056 |
| U | 5.8 | 40.3 | R | 0.065 |
| O | 6 | 8 | S | 0.11 |
| O | 6 | 32 | S | 0.04 |
| O | 6 | 30 | R | 0.07 |
| O | 6 | 31 | R | 0.08 |
| D | 6.1 | 16.1 | S | 0.411 |
| D | 6.1 | 63.6 | S | 0.018 |
| D | 6.1 | 6.6 | R | 0.509 |
| D | 6.1 | 9.3 | R | 0.467 |
| D | 6.1 | 13 | R | 0.279 |
| D | 6.1 | 17.3 | R | 0.072 |
| D | 6.1 | 105 | R | 0.012 |
| D | 6.1 | 112 | R | 0.006 |
| D | 6.1 | 123 | R | 0.003 |
| L | 6.2 | 5 | R | 0.39 |
| S | 6.5 | 23.5 | S | 0.17 |
| S | 6.5 | 26 | S | 0.21 |
| S | 6.5 | 0.5 | R | 0.32 |
| S | 6.5 | 0.6 | R | 0.52 |
| S | 6.5 | 1.3 | R | 0.72 |
| S | 6.5 | 1.4 | R | 0.32 |
| … | … | … | … | … |
(def seatac (nu/dataset :seatac-weather))| month | day | year | max-temp | record-max | normal-max | min-temp | record-min | normal-min | precip | record-precip | normal-precip | time-max | time-min |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| January | 1 | 2007 | 43 | 58 | 45 | 34 | 10 | 35 | 0.13 | 1.37 | 0.17 | 1509 | 13 |
| January | 2 | 2007 | 56 | 56 | 45 | 45 | 6 | 35 | 1.77 | 1.51 | 0.17 | 1000 | 135 |
| January | 3 | 2007 | 48 | 58 | 45 | 43 | 6 | 35 | 1.01 | 1.01 | 0.17 | 1411 | 713 |
| January | 4 | 2007 | 42 | 61 | 45 | 37 | 14 | 36 | 0.06 | 1.56 | 0.17 | 1535 | 1732 |
| January | 5 | 2007 | 43 | 55 | 45 | 31 | 15 | 36 | 0.19 | 1.33 | 0.17 | 1312 | 55 |
| January | 6 | 2007 | 44 | 57 | 45 | 36 | 14 | 36 | 1.22 | 0.17 | 23 | 809 | |
| January | 7 | 2007 | 49 | 59 | 45 | 40 | 19 | 36 | 0.93 | 1.33 | 0.17 | 1544 | 127 |
| January | 8 | 2007 | 47 | 54 | 45 | 38 | 18 | 36 | 0 | 1.13 | 0.17 | 1659 | 659 |
| January | 9 | 2007 | 51 | 56 | 45 | 41 | 13 | 36 | 0.16 | 2.83 | 0.17 | 1415 | 1659 |
| January | 10 | 2007 | 36 | 59 | 45 | 32 | 12 | 36 | 0.01 | 0.94 | 0.17 | 1558 | 607 |
| January | 11 | 2007 | 31 | 59 | 45 | 27 | 12 | 36 | 0 | 1.26 | 0.17 | 1401 | 724 |
| January | 12 | 2007 | 31 | 59 | 45 | 19 | 13 | 36 | 1.3 | 0.17 | 1523 | 842 | |
| January | 13 | 2007 | 29 | 56 | 45 | 21 | 11 | 36 | 0 | 1.63 | 0.17 | 1658 | 605 |
| January | 14 | 2007 | 35 | 59 | 45 | 20 | 8 | 36 | 1.61 | 0.17 | 1453 | 803 | |
| January | 15 | 2007 | 35 | 58 | 46 | 23 | 15 | 36 | 1.68 | 0.17 | 1443 | 934 | |
| January | 16 | 2007 | 35 | 54 | 46 | 28 | 13 | 36 | 0.18 | 1.78 | 0.17 | 1632 | 619 |
| January | 17 | 2007 | 39 | 55 | 46 | 33 | 15 | 36 | 2.39 | 0.17 | 1349 | 850 | |
| January | 18 | 2007 | 42 | 60 | 46 | 34 | 9 | 36 | 0.16 | 2.98 | 0.16 | 1659 | 434 |
| January | 19 | 2007 | 42 | 62 | 46 | 38 | 18 | 36 | 0.08 | 2.26 | 0.16 | 1659 | 936 |
| January | 20 | 2007 | 45 | 64 | 46 | 37 | 16 | 36 | 1.66 | 0.16 | 1549 | 703 | |
| January | 21 | 2007 | 42 | 62 | 46 | 37 | 13 | 36 | 1.64 | 0.16 | 1659 | 827 | |
| January | 22 | 2007 | 50 | 60 | 46 | 40 | 19 | 36 | 0 | 1.29 | 0.16 | 1617 | 147 |
| January | 23 | 2007 | 52 | 56 | 46 | 44 | 16 | 36 | 0 | 1.36 | 0.16 | 1553 | 559 |
| January | 24 | 2007 | 51 | 58 | 47 | 35 | 10 | 36 | 1.36 | 0.16 | 1328 | 752 | |
| January | 25 | 2007 | 43 | 58 | 47 | 33 | 7 | 36 | 0.02 | 0.93 | 0.16 | 1602 | 744 |
| January | 26 | 2007 | 44 | 58 | 47 | 37 | 9 | 36 | 1.03 | 0.16 | 1558 | 1058 | |
| January | 27 | 2007 | 52 | 58 | 47 | 32 | 11 | 36 | 1.61 | 0.16 | 1419 | 840 | |
| January | 28 | 2007 | 50 | 57 | 47 | 28 | 7 | 36 | 1.23 | 0.16 | 1436 | 711 | |
| January | 29 | 2007 | 40 | 60 | 47 | 28 | 6 | 36 | 1.63 | 0.16 | 1618 | 542 | |
| January | 30 | 2007 | 48 | 59 | 47 | 33 | 7 | 36 | 1 | 0.16 | 1618 | 715 | |
| January | 31 | 2007 | 48 | 61 | 47 | 28 | 0 | 36 | 1.93 | 0.16 | 1529 | 638 | |
| February | 1 | 2007 | 49 | 63 | 48 | 30 | 1 | 36 | 1.34 | 0.16 | 1619 | 523 | |
| February | 2 | 2007 | 44 | 64 | 48 | 28 | 8 | 37 | 1.32 | 0.16 | 1325 | 529 | |
| February | 3 | 2007 | 42 | 63 | 48 | 31 | 8 | 37 | 0.12 | 1.29 | 0.16 | 1056 | 301 |
| February | 4 | 2007 | 54 | 63 | 48 | 41 | 7 | 37 | 0.16 | 0.91 | 0.16 | 1456 | 601 |
| February | 5 | 2007 | 45 | 62 | 48 | 42 | 14 | 37 | 0.96 | 0.16 | 1434 | 1013 | |
| February | 6 | 2007 | 48 | 64 | 48 | 41 | 18 | 37 | 0.03 | 1.54 | 0.16 | 1646 | 939 |
| February | 7 | 2007 | 51 | 66 | 49 | 43 | 20 | 37 | 0 | 2.58 | 0.15 | 1659 | 525 |
| February | 8 | 2007 | 53 | 68 | 49 | 42 | 22 | 37 | 0.01 | 3.06 | 0.15 | 1349 | 701 |
| February | 9 | 2007 | 57 | 62 | 49 | 42 | 26 | 37 | 0.08 | 2.98 | 0.15 | 1553 | 639 |
| February | 10 | 2007 | 56 | 65 | 49 | 42 | 24 | 37 | 0.96 | 0.15 | 1424 | 607 | |
| February | 11 | 2007 | 54 | 62 | 49 | 45 | 27 | 37 | 0.11 | 0.81 | 0.15 | 1434 | 851 |
| February | 12 | 2007 | 53 | 66 | 49 | 42 | 21 | 37 | 0 | 1.23 | 0.15 | 1356 | 727 |
| February | 13 | 2007 | 51 | 59 | 49 | 41 | 18 | 37 | 0.02 | 1.4 | 0.15 | 1617 | 711 |
| February | 14 | 2007 | 46 | 63 | 49 | 40 | 22 | 37 | 0.15 | 0.74 | 0.15 | 1122 | 128 |
| February | 15 | 2007 | 53 | 65 | 50 | 46 | 13 | 37 | 0.12 | 0.94 | 0.15 | 1501 | 600 |
| February | 16 | 2007 | 51 | 58 | 50 | 43 | 13 | 37 | 0.01 | 1.83 | 0.15 | 1520 | 725 |
| February | 17 | 2007 | 58 | 58 | 50 | 44 | 23 | 37 | 0.65 | 0.15 | 1436 | 732 | |
| February | 18 | 2007 | 46 | 62 | 50 | 41 | 20 | 37 | 1.63 | 0.15 | 1357 | 740 | |
| February | 19 | 2007 | 46 | 67 | 50 | 41 | 22 | 37 | 0.17 | 1.76 | 0.15 | 1553 | 237 |
| February | 20 | 2007 | 44 | 62 | 50 | 37 | 25 | 37 | 0.25 | 0.74 | 0.15 | 41 | 1412 |
| February | 21 | 2007 | 50 | 67 | 50 | 34 | 25 | 37 | 0.02 | 0.97 | 0.14 | 1528 | 610 |
| February | 22 | 2007 | 48 | 64 | 50 | 37 | 30 | 38 | 0.13 | 0.71 | 0.14 | 1513 | 718 |
| February | 23 | 2007 | 44 | 61 | 51 | 35 | 28 | 38 | 0.01 | 1.16 | 0.14 | 1552 | 809 |
| February | 24 | 2007 | 44 | 62 | 51 | 36 | 25 | 38 | 0.36 | 1.55 | 0.14 | 1510 | 633 |
| February | 25 | 2007 | 45 | 64 | 51 | 39 | 22 | 38 | 0.15 | 0.8 | 0.14 | 1659 | 231 |
| February | 26 | 2007 | 47 | 67 | 51 | 38 | 18 | 38 | 0.03 | 1.19 | 0.14 | 1410 | 839 |
| February | 27 | 2007 | 42 | 70 | 51 | 31 | 20 | 38 | 0 | 2.23 | 0.14 | 1619 | 709 |
| February | 28 | 2007 | 41 | 68 | 51 | 34 | 24 | 38 | 0.04 | 1.46 | 0.14 | 1445 | 839 |
| March | 1 | 2007 | 41 | 62 | 51 | 31 | 23 | 38 | 0 | 0.84 | 0.14 | 1238 | 733 |
| March | 2 | 2007 | 43 | 64 | 51 | 32 | 22 | 38 | 0.08 | 1.16 | 0.14 | 1630 | 256 |
| March | 3 | 2007 | 52 | 69 | 52 | 41 | 20 | 38 | 0.05 | 2.08 | 0.13 | 1659 | 252 |
| March | 4 | 2007 | 55 | 68 | 52 | 41 | 11 | 38 | 0.92 | 0.13 | 1633 | 636 | |
| March | 5 | 2007 | 59 | 66 | 52 | 46 | 13 | 38 | 0.06 | 2.7 | 0.13 | 1659 | 708 |
| March | 6 | 2007 | 68 | 64 | 52 | 41 | 26 | 38 | 1.18 | 0.13 | 1412 | 654 | |
| March | 7 | 2007 | 54 | 66 | 52 | 47 | 26 | 38 | 0.14 | 0.67 | 0.13 | 0 | 1251 |
| March | 8 | 2007 | 50 | 67 | 52 | 42 | 28 | 39 | 0.16 | 1.01 | 0.13 | 1232 | 750 |
| March | 9 | 2007 | 53 | 67 | 52 | 43 | 28 | 39 | 0.03 | 0.83 | 0.13 | 1259 | 601 |
| March | 10 | 2007 | 57 | 68 | 52 | 47 | 20 | 39 | 0.08 | 0.87 | 0.13 | 1311 | 736 |
| March | 11 | 2007 | 65 | 52 | 23 | 39 | 0.42 | 1.01 | 0.13 | ||||
| March | 12 | 2007 | 53 | 68 | 53 | 46 | 25 | 39 | 0.1 | 0.99 | 0.13 | 30 | 709 |
| March | 13 | 2007 | 49 | 70 | 53 | 36 | 28 | 39 | 0 | 0.7 | 0.12 | 1336 | 653 |
| March | 14 | 2007 | 48 | 64 | 53 | 38 | 26 | 39 | 0.76 | 0.12 | 1547 | 708 | |
| March | 15 | 2007 | 47 | 61 | 53 | 34 | 30 | 39 | 0 | 1.2 | 0.12 | 1410 | 457 |
| March | 16 | 2007 | 66 | 66 | 53 | 42 | 29 | 39 | 0 | 0.98 | 0.12 | 1545 | 107 |
| March | 17 | 2007 | 52 | 65 | 53 | 47 | 27 | 39 | 0.09 | 1.05 | 0.12 | 1542 | 740 |
| March | 18 | 2007 | 61 | 70 | 53 | 48 | 29 | 39 | 0.02 | 1.86 | 0.12 | 1603 | 729 |
| March | 19 | 2007 | 51 | 63 | 54 | 48 | 27 | 39 | 0.25 | 1.27 | 0.12 | 1311 | 1659 |
| March | 20 | 2007 | 50 | 69 | 54 | 40 | 26 | 39 | 0.1 | 0.76 | 0.12 | 1256 | 1449 |
| March | 21 | 2007 | 51 | 69 | 54 | 32 | 29 | 39 | 0.82 | 0.12 | 1437 | 542 | |
| March | 22 | 2007 | 51 | 68 | 54 | 44 | 28 | 40 | 0.07 | 1.81 | 0.11 | 1105 | 111 |
| March | 23 | 2007 | 51 | 68 | 54 | 46 | 28 | 40 | 0.09 | 0.94 | 0.11 | 1659 | 638 |
| March | 24 | 2007 | 53 | 66 | 54 | 50 | 30 | 40 | 0.85 | 0.98 | 0.11 | 114 | 1659 |
| March | 25 | 2007 | 54 | 64 | 54 | 43 | 31 | 40 | 0.01 | 0.51 | 0.11 | 1608 | 752 |
| March | 26 | 2007 | 59 | 70 | 55 | 36 | 32 | 40 | 1.51 | 0.11 | 1419 | 535 | |
| March | 27 | 2007 | 50 | 71 | 55 | 41 | 26 | 40 | 0.24 | 0.64 | 0.11 | 1456 | 643 |
| March | 28 | 2007 | 54 | 73 | 55 | 37 | 26 | 40 | 0.53 | 0.11 | 1421 | 633 | |
| March | 29 | 2007 | 63 | 78 | 55 | 37 | 24 | 40 | 0.7 | 0.11 | 1410 | 553 | |
| March | 30 | 2007 | 53 | 72 | 55 | 44 | 27 | 40 | 0.06 | 0.65 | 0.11 | 1121 | 232 |
| March | 31 | 2007 | 50 | 75 | 55 | 41 | 30 | 40 | 0.18 | 0.57 | 0.1 | 1348 | 806 |
(def us-arrests (nu/dataset :us-arrests))| state | murder | assault | urban-pop | rape |
|---|---|---|---|---|
| Alabama | 13.2 | 236 | 58 | 21.2 |
| Alaska | 10 | 263 | 48 | 44.5 |
| Arizona | 8.1 | 294 | 80 | 31 |
| Arkansas | 8.8 | 190 | 50 | 19.5 |
| California | 9 | 276 | 91 | 40.6 |
| Colorado | 7.9 | 204 | 78 | 38.7 |
| Connecticut | 3.3 | 110 | 77 | 11.1 |
| Delaware | 5.9 | 238 | 72 | 15.8 |
| Florida | 15.4 | 335 | 80 | 31.9 |
| Georgia | 17.4 | 211 | 60 | 25.8 |
| Hawaii | 5.3 | 46 | 83 | 20.2 |
| Idaho | 2.6 | 120 | 54 | 14.2 |
| Illinois | 10.4 | 249 | 83 | 24 |
| Indiana | 7.2 | 113 | 65 | 21 |
| Iowa | 2.2 | 56 | 57 | 11.3 |
| Kansas | 6 | 115 | 66 | 18 |
| Kentucky | 9.7 | 109 | 52 | 16.3 |
| Louisiana | 15.4 | 249 | 66 | 22.2 |
| Maine | 2.1 | 83 | 51 | 7.8 |
| Maryland | 11.3 | 300 | 67 | 27.8 |
| Massachusetts | 4.4 | 149 | 85 | 16.3 |
| Michigan | 12.1 | 255 | 74 | 35.1 |
| Minnesota | 2.7 | 72 | 66 | 14.9 |
| Mississippi | 16.1 | 259 | 44 | 17.1 |
| Missouri | 9 | 178 | 70 | 28.2 |
| Montana | 6 | 109 | 53 | 16.4 |
| Nebraska | 4.3 | 102 | 62 | 16.5 |
| Nevada | 12.2 | 252 | 81 | 46 |
| New Hampshire | 2.1 | 57 | 56 | 9.5 |
| New Jersey | 7.4 | 159 | 89 | 18.8 |
| New Mexico | 11.4 | 285 | 70 | 32.1 |
| New York | 11.1 | 254 | 86 | 26.1 |
| North Carolina | 13 | 337 | 45 | 16.1 |
| North Dakota | 0.8 | 45 | 44 | 7.3 |
| Ohio | 7.3 | 120 | 75 | 21.4 |
| Oklahoma | 6.6 | 151 | 68 | 20 |
| Oregon | 4.9 | 159 | 67 | 29.3 |
| Pennsylvania | 6.3 | 106 | 72 | 14.9 |
| Rhode Island | 3.4 | 174 | 87 | 8.3 |
| South Carolina | 14.4 | 279 | 48 | 22.5 |
| South Dakota | 3.8 | 86 | 45 | 12.8 |
| Tennessee | 13.2 | 188 | 59 | 26.9 |
| Texas | 12.7 | 201 | 80 | 25.5 |
| Utah | 3.2 | 120 | 80 | 22.9 |
| Vermont | 2.2 | 48 | 32 | 11.2 |
| Virginia | 8.5 | 156 | 63 | 20.7 |
| Washington | 4 | 145 | 73 | 26.2 |
| West Virginia | 5.7 | 81 | 39 | 9.3 |
| Wisconsin | 2.6 | 53 | 66 | 10.8 |
| Wyoming | 6.8 | 161 | 60 | 15.6 |
(def states (nu/dataset :states))| name | abb | region | division | long | lat | population | income | illiteracy | life-exp | murder | hs-grad | frost | area |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Alabama | AL | South | East South Central | -86.7509 | 32.5901 | 3615 | 3624 | 2.1 | 69.05 | 15.1 | 41.3 | 20 | 50708 |
| Alaska | AK | West | Pacific | -127.25 | 49.25 | 365 | 6315 | 1.5 | 69.31 | 11.3 | 66.7 | 152 | 566432 |
| Arizona | AZ | West | Mountain | -111.625 | 34.2192 | 2212 | 4530 | 1.8 | 70.55 | 7.8 | 58.1 | 15 | 113417 |
| Arkansas | AR | South | West South Central | -92.2992 | 34.7336 | 2110 | 3378 | 1.9 | 70.66 | 10.1 | 39.9 | 65 | 51945 |
| California | CA | West | Pacific | -119.773 | 36.5341 | 21198 | 5114 | 1.1 | 71.71 | 10.3 | 62.6 | 20 | 156361 |
| Colorado | CO | West | Mountain | -105.513 | 38.6777 | 2541 | 4884 | 0.7 | 72.06 | 6.8 | 63.9 | 166 | 103766 |
| Connecticut | CT | Northeast | New England | -72.3573 | 41.5928 | 3100 | 5348 | 1.1 | 72.48 | 3.1 | 56 | 139 | 4862 |
| Delaware | DE | South | South Atlantic | -74.9841 | 38.6777 | 579 | 4809 | 0.9 | 70.06 | 6.2 | 54.6 | 103 | 1982 |
| Florida | FL | South | South Atlantic | -81.685 | 27.8744 | 8277 | 4815 | 1.3 | 70.66 | 10.7 | 52.6 | 11 | 54090 |
| Georgia | GA | South | South Atlantic | -83.3736 | 32.3329 | 4931 | 4091 | 2 | 68.54 | 13.9 | 40.6 | 60 | 58073 |
| Hawaii | HI | West | Pacific | -126.25 | 31.75 | 868 | 4963 | 1.9 | 73.6 | 6.2 | 61.9 | 0 | 6425 |
| Idaho | ID | West | Mountain | -113.93 | 43.5648 | 813 | 4119 | 0.6 | 71.87 | 5.3 | 59.5 | 126 | 82677 |
| Illinois | IL | North Central | East North Central | -89.3776 | 40.0495 | 11197 | 5107 | 0.9 | 70.14 | 10.3 | 52.6 | 127 | 55748 |
| Indiana | IN | North Central | East North Central | -86.0808 | 40.0495 | 5313 | 4458 | 0.7 | 70.88 | 7.1 | 52.9 | 122 | 36097 |
| Iowa | IA | North Central | West North Central | -93.3714 | 41.9358 | 2861 | 4628 | 0.5 | 72.56 | 2.3 | 59 | 140 | 55941 |
| Kansas | KS | North Central | West North Central | -98.1156 | 38.4204 | 2280 | 4669 | 0.6 | 72.58 | 4.5 | 59.9 | 114 | 81787 |
| Kentucky | KY | South | East South Central | -84.7674 | 37.3915 | 3387 | 3712 | 1.6 | 70.1 | 10.6 | 38.5 | 95 | 39650 |
| Louisiana | LA | South | West South Central | -92.2724 | 30.6181 | 3806 | 3545 | 2.8 | 68.76 | 13.2 | 42.2 | 12 | 44930 |
| Maine | ME | Northeast | New England | -68.9801 | 45.6226 | 1058 | 3694 | 0.7 | 70.39 | 2.7 | 54.7 | 161 | 30920 |
| Maryland | MD | South | South Atlantic | -76.6459 | 39.2778 | 4122 | 5299 | 0.9 | 70.22 | 8.5 | 52.3 | 101 | 9891 |
| Massachusetts | MA | Northeast | New England | -71.58 | 42.3645 | 5814 | 4755 | 1.1 | 71.83 | 3.3 | 58.5 | 103 | 7826 |
| Michigan | MI | North Central | East North Central | -84.687 | 43.1361 | 9111 | 4751 | 0.9 | 70.63 | 11.1 | 52.8 | 125 | 56817 |
| Minnesota | MN | North Central | West North Central | -94.6043 | 46.3943 | 3921 | 4675 | 0.6 | 72.96 | 2.3 | 57.6 | 160 | 79289 |
| Mississippi | MS | South | East South Central | -89.8065 | 32.6758 | 2341 | 3098 | 2.4 | 68.09 | 12.5 | 41 | 50 | 47296 |
| Missouri | MO | North Central | West North Central | -92.5137 | 38.3347 | 4767 | 4254 | 0.8 | 70.69 | 9.3 | 48.8 | 108 | 68995 |
| Montana | MT | West | Mountain | -109.32 | 46.823 | 746 | 4347 | 0.6 | 70.56 | 5 | 59.2 | 155 | 145587 |
| Nebraska | NE | North Central | West North Central | -99.5898 | 41.3356 | 1544 | 4508 | 0.6 | 72.6 | 2.9 | 59.3 | 139 | 76483 |
| Nevada | NV | West | Mountain | -116.851 | 39.1063 | 590 | 5149 | 0.5 | 69.03 | 11.5 | 65.2 | 188 | 109889 |
| New Hampshire | NH | Northeast | New England | -71.3924 | 43.3934 | 812 | 4281 | 0.7 | 71.23 | 3.3 | 57.6 | 174 | 9027 |
| New Jersey | NJ | Northeast | Middle Atlantic | -74.2336 | 39.9637 | 7333 | 5237 | 1.1 | 70.93 | 5.2 | 52.5 | 115 | 7521 |
| New Mexico | NM | West | Mountain | -105.942 | 34.4764 | 1144 | 3601 | 2.2 | 70.32 | 9.7 | 55.2 | 120 | 121412 |
| New York | NY | Northeast | Middle Atlantic | -75.1449 | 43.1361 | 18076 | 4903 | 1.4 | 70.55 | 10.9 | 52.7 | 82 | 47831 |
| North Carolina | NC | South | South Atlantic | -78.4686 | 35.4195 | 5441 | 3875 | 1.8 | 69.21 | 11.1 | 38.5 | 80 | 48798 |
| North Dakota | ND | North Central | West North Central | -100.099 | 47.2517 | 637 | 5087 | 0.8 | 72.78 | 1.4 | 50.3 | 186 | 69273 |
| Ohio | OH | North Central | East North Central | -82.5963 | 40.221 | 10735 | 4561 | 0.8 | 70.82 | 7.4 | 53.2 | 124 | 40975 |
| Oklahoma | OK | South | West South Central | -97.1239 | 35.5053 | 2715 | 3983 | 1.1 | 71.42 | 6.4 | 51.6 | 82 | 68782 |
| Oregon | OR | West | Pacific | -120.068 | 43.9078 | 2284 | 4660 | 0.6 | 72.13 | 4.2 | 60 | 44 | 96184 |
| Pennsylvania | PA | Northeast | Middle Atlantic | -77.45 | 40.9069 | 11860 | 4449 | 1 | 70.43 | 6.1 | 50.2 | 126 | 44966 |
| Rhode Island | RI | Northeast | New England | -71.1244 | 41.5928 | 931 | 4558 | 1.3 | 71.9 | 2.4 | 46.4 | 127 | 1049 |
| South Carolina | SC | South | South Atlantic | -80.5056 | 33.619 | 2816 | 3635 | 2.3 | 67.96 | 11.6 | 37.8 | 65 | 30225 |
| South Dakota | SD | North Central | West North Central | -99.7238 | 44.3365 | 681 | 4167 | 0.5 | 72.08 | 1.7 | 53.3 | 172 | 75955 |
| Tennessee | TN | South | East South Central | -86.456 | 35.6767 | 4173 | 3821 | 1.7 | 70.11 | 11 | 41.8 | 70 | 41328 |
| Texas | TX | South | West South Central | -98.7857 | 31.3897 | 12237 | 4188 | 2.2 | 70.9 | 12.2 | 47.4 | 35 | 262134 |
| Utah | UT | West | Mountain | -111.33 | 39.1063 | 1203 | 4022 | 0.6 | 72.9 | 4.5 | 67.3 | 137 | 82096 |
| Vermont | VT | Northeast | New England | -72.545 | 44.2508 | 472 | 3907 | 0.6 | 71.64 | 5.5 | 57.1 | 168 | 9267 |
| Virginia | VA | South | South Atlantic | -78.2005 | 37.563 | 4981 | 4701 | 1.4 | 70.08 | 9.5 | 47.8 | 85 | 39780 |
| Washington | WA | West | Pacific | -119.746 | 47.4231 | 3559 | 4864 | 0.6 | 71.72 | 4.3 | 63.5 | 32 | 66570 |
| West Virginia | WV | South | South Atlantic | -80.6665 | 38.4204 | 1799 | 3617 | 1.4 | 69.48 | 6.7 | 41.6 | 100 | 24070 |
| Wisconsin | WI | North Central | East North Central | -89.9941 | 44.5937 | 4589 | 4468 | 0.7 | 72.48 | 3 | 54.5 | 149 | 54464 |
| Wyoming | WY | West | Mountain | -107.256 | 43.0504 | 376 | 4566 | 0.6 | 70.29 | 6.9 | 62.9 | 173 | 97203 |
(def mtcars (nu/dataset :mtcars))| model | mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.46 | 0 | 1 | 4 | 4 |
| Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 | 2.875 | 17.02 | 0 | 1 | 4 | 4 |
| Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 | 2.32 | 18.61 | 1 | 1 | 4 | 1 |
| Hornet 4 Drive | 21.4 | 6 | 258 | 110 | 3.08 | 3.215 | 19.44 | 1 | 0 | 3 | 1 |
| Hornet Sportabout | 18.7 | 8 | 360 | 175 | 3.15 | 3.44 | 17.02 | 0 | 0 | 3 | 2 |
| Valiant | 18.1 | 6 | 225 | 105 | 2.76 | 3.46 | 20.22 | 1 | 0 | 3 | 1 |
| Duster 360 | 14.3 | 8 | 360 | 245 | 3.21 | 3.57 | 15.84 | 0 | 0 | 3 | 4 |
| Merc 240D | 24.4 | 4 | 146.7 | 62 | 3.69 | 3.19 | 20 | 1 | 0 | 4 | 2 |
| Merc 230 | 22.8 | 4 | 140.8 | 95 | 3.92 | 3.15 | 22.9 | 1 | 0 | 4 | 2 |
| Merc 280 | 19.2 | 6 | 167.6 | 123 | 3.92 | 3.44 | 18.3 | 1 | 0 | 4 | 4 |
| Merc 280C | 17.8 | 6 | 167.6 | 123 | 3.92 | 3.44 | 18.9 | 1 | 0 | 4 | 4 |
| Merc 450SE | 16.4 | 8 | 275.8 | 180 | 3.07 | 4.07 | 17.4 | 0 | 0 | 3 | 3 |
| Merc 450SL | 17.3 | 8 | 275.8 | 180 | 3.07 | 3.73 | 17.6 | 0 | 0 | 3 | 3 |
| Merc 450SLC | 15.2 | 8 | 275.8 | 180 | 3.07 | 3.78 | 18 | 0 | 0 | 3 | 3 |
| Cadillac Fleetwood | 10.4 | 8 | 472 | 205 | 2.93 | 5.25 | 17.98 | 0 | 0 | 3 | 4 |
| Lincoln Continental | 10.4 | 8 | 460 | 215 | 3 | 5.424 | 17.82 | 0 | 0 | 3 | 4 |
| Chrysler Imperial | 14.7 | 8 | 440 | 230 | 3.23 | 5.345 | 17.42 | 0 | 0 | 3 | 4 |
| Fiat 128 | 32.4 | 4 | 78.7 | 66 | 4.08 | 2.2 | 19.47 | 1 | 1 | 4 | 1 |
| Honda Civic | 30.4 | 4 | 75.7 | 52 | 4.93 | 1.615 | 18.52 | 1 | 1 | 4 | 2 |
| Toyota Corolla | 33.9 | 4 | 71.1 | 65 | 4.22 | 1.835 | 19.9 | 1 | 1 | 4 | 1 |
| Toyota Corona | 21.5 | 4 | 120.1 | 97 | 3.7 | 2.465 | 20.01 | 1 | 0 | 3 | 1 |
| Dodge Challenger | 15.5 | 8 | 318 | 150 | 2.76 | 3.52 | 16.87 | 0 | 0 | 3 | 2 |
| AMC Javelin | 15.2 | 8 | 304 | 150 | 3.15 | 3.435 | 17.3 | 0 | 0 | 3 | 2 |
| Camaro Z28 | 13.3 | 8 | 350 | 245 | 3.73 | 3.84 | 15.41 | 0 | 0 | 3 | 4 |
| Pontiac Firebird | 19.2 | 8 | 400 | 175 | 3.08 | 3.845 | 17.05 | 0 | 0 | 3 | 2 |
| Fiat X1-9 | 27.3 | 4 | 79 | 66 | 4.08 | 1.935 | 18.9 | 1 | 1 | 4 | 1 |
| Porsche 914-2 | 26 | 4 | 120.3 | 91 | 4.43 | 2.14 | 16.7 | 0 | 1 | 5 | 2 |
| Lotus Europa | 30.4 | 4 | 95.1 | 113 | 3.77 | 1.513 | 16.9 | 1 | 1 | 5 | 2 |
| Ford Pantera L | 15.8 | 8 | 351 | 264 | 4.22 | 3.17 | 14.5 | 0 | 1 | 5 | 4 |
| Ferrari Dino | 19.7 | 6 | 145 | 175 | 3.62 | 2.77 | 15.5 | 0 | 1 | 5 | 6 |
| Maserati Bora | 15 | 8 | 301 | 335 | 3.54 | 3.57 | 14.6 | 0 | 1 | 5 | 8 |
| Volvo 142E | 21.4 | 4 | 121 | 109 | 4.11 | 2.78 | 18.6 | 1 | 1 | 4 | 2 |
38.1 Chapter 1 - Introduction
38.1.1 Fig 1.1 Histograms
GCSE scores of the A-level chemistry candidates, a panel per A-level score.
Source: Lattice Fig 1.1. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97
:mapping {:x :gcsescore :facet :score}
:charts [(chart/histogram)]
:facets {:columns 3}
:labels {:x "gcsescore" :y "Percent of Total"}}
{:width 800 :height 500})
38.1.2 Fig 1.2 Densities
Source: Lattice Fig 1.2. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97
:mapping {:x :gcsescore :facet :score}
:charts [(chart/density)]
:facets {:columns 3}
:labels {:x "gcsescore" :y "Density"}}
{:width 800 :height 500})
38.1.3 Fig 1.3 Grouped densities
The six densities in one panel, coloured by score; the score is a number, declared categorical for the colours.
Source: Lattice Fig 1.3. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97
:mapping {:x :gcsescore :color :score}
:scales {:color {:type :categorical}}
:charts [(chart/density)]
:labels {:x "gcsescore" :y "Density"}}
{:width 700 :height 450})
38.1.4 Fig 1.4 Two plots on a page
Source: Lattice Fig 1.4. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
(plot/arrange [{:data chem97
:mapping {:x :gcsescore :facet :score}
:charts [(chart/histogram)]
:facets {:columns 2}
:labels {:x "gcsescore" :y "Percent of Total"}}
{:data chem97
:mapping {:x :gcsescore :color :score}
:scales {:color {:type :categorical :title "score"}}
:charts [(chart/density)]
:labels {:x "gcsescore" :y "Density"}}]
{:columns 1})
{:width 600 :height 800})
38.2 Chapter 2 - A Technical Overview of lattice
38.2.1 Fig 2.1 Two conditioning variables
Oat yield by nitrogen, a panel per variety (columns) and block (rows): points joined by lines.
Source: Lattice Fig 2.1. Data: Oats yields: split-plot field trial, R MEMSS package Oats (Yates 1935; Pinheiro & Bates 2000); licence: GPL (>= 2) (MEMSS).
(plot/render-image
{:data oats
:mapping {:x :nitro :y :yield :facet-col :variety :facet-row :block}
:charts [(chart/line) (chart/scatter)]
:labels {:x "nitro" :y "yield"}}
{:width 700 :height 800})
38.2.2 Fig 2.2 One block
Source: Lattice Fig 2.2. Data: Oats yields: split-plot field trial, R MEMSS package Oats (Yates 1935; Pinheiro & Bates 2000); licence: GPL (>= 2) (MEMSS).
(plot/render-image
{:data (filterv #(= "I" (:block %)) oats)
:mapping {:x :nitro :y :yield :facet :variety}
:charts [(chart/line) (chart/scatter)]
:facets {:columns 3}
:labels {:x "nitro" :y "yield"}}
{:width 800 :height 450})
38.2.3 Fig 2.3 Banked to 45 degrees
Lattice’s aspect = "xy" chooses the panel shape from the slopes of the lines; here the image is narrow instead.
Source: Lattice Fig 2.3. Data: Oats yields: split-plot field trial, R MEMSS package Oats (Yates 1935; Pinheiro & Bates 2000); licence: GPL (>= 2) (MEMSS).
(plot/render-image
{:data oats
:mapping {:x :nitro :y :yield :facet-col :variety :facet-row :block}
:charts [(chart/line) (chart/scatter {:size 3})]
:labels {:x "nitro" :y "yield"}}
{:width 380 :height 800})
38.2.4 Fig 2.4 Eighteen panels in three rows
Source: Lattice Fig 2.4. Data: Oats yields: split-plot field trial, R MEMSS package Oats (Yates 1935; Pinheiro & Bates 2000); licence: GPL (>= 2) (MEMSS).
(plot/render-image
{:data oats
:mapping {:x :nitro :y :yield :facet #(str (:block %) " " (:variety %))}
:charts [(chart/line) (chart/scatter {:size 3})]
:facets {:columns 6}
:labels {:x "nitro" :y "yield"}}
{:width 1000 :height 550})
38.2.5 Fig 2.5 Gaps between blocks
Lattice widens chosen gaps between panels (between); here each block is its own plot, arranged.
Source: Lattice Fig 2.5. Data: Oats yields: split-plot field trial, R MEMSS package Oats (Yates 1935; Pinheiro & Bates 2000); licence: GPL (>= 2) (MEMSS).
(plot/render-image
(plot/arrange (for [block ["I" "II" "III" "IV" "V" "VI"]]
{:data (filterv #(= block (:block %)) oats)
:mapping {:x :nitro :y :yield :facet :variety}
:charts [(chart/line) (chart/scatter {:size 3})]
:scales {:y {:domain [50 180]}}
:facets {:columns 3}
:labels {:title (str "Block " block) :x nil :y nil}})
{:columns 2})
{:width 1000 :height 700})
38.2.6 Fig 2.6 Dot plot
Barley yield of each variety at six sites, the two years in two shapes. Sites, varieties and years keep R’s factor order (nu/levels); lattice fills panels from the bottom, so the sites run top-down reversed.
Source: Lattice Fig 2.6. Data: Barley yields, Minnesota 1931-1932, R lattice package barley (Immer et al. 1934; Fisher 1971; Cleveland 1993); licence: GPL (>= 2) (lattice).
(plot/render-image
{:data barley
:mapping {:x :yield :y :variety :shape :year :facet :site}
:scales {:y {:domain (nu/levels :barley :variety)}
:facet {:domain (vec (rseq (nu/levels :barley :site)))}
:shape {:domain (nu/levels :barley :year)}}
:charts [(chart/scatter)]
:facets {:columns 1}
:theme {:text {:tick-label {:size 8}}}
:labels {:x "yield" :y nil}}
{:width 600 :height 800})
38.2.7 Fig 2.7 Groups within panels
Source: Lattice Fig 2.7. Data: Oats yields: split-plot field trial, R MEMSS package Oats (Yates 1935; Pinheiro & Bates 2000); licence: GPL (>= 2) (MEMSS).
(plot/render-image
{:data oats
:mapping {:x :nitro :y :yield :shape :variety :group :variety :facet :block}
:charts [(chart/line {:color :darkgrey}) (chart/scatter {:color :black :size 6})]
:facets {:columns 6}
:labels {:title "Yield of three varieties of oats - a 3 x 4 split plot experiment with 6 blocks"
:x "Nitrogen concentration (cwt/acre)" :y "Yield (bushels/acre)"}}
{:width 1000 :height 400})
38.2.8 Fig 2.8 Stacked bars
Titanic passengers by class, stacked by survival, a panel per age and sex.
Source: Lattice Fig 2.8. Data: Titanic passengers and crew by class, sex, age and survival, R datasets package Titanic (Dawson 1995); licence: Part of R (GPL-2 | GPL-3).
(def titanic-panels ["Child Male" "Child Female" "Adult Male" "Adult Female"])(plot/render-image
{:data titanic
:mapping {:x :n :y :class :color :survived :facet #(str (:age %) " " (:sex %))}
:scales {:facet {:domain titanic-panels}}
:charts [(chart/bar {:position :stack})]
:facets {:columns 4}
:theme {:panel {:grid {:x :none :y :none}}}
:labels {:x "Freq" :y nil}}
{:width 900 :height 350})
38.2.9 Fig 2.9 Free scales
Each panel its own count axis, so the small groups are readable.
Source: Lattice Fig 2.9. Data: Titanic passengers and crew by class, sex, age and survival, R datasets package Titanic (Dawson 1995); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data titanic
:mapping {:x :n :y :class :color :survived :facet #(str (:age %) " " (:sex %))}
:scales {:facet {:domain titanic-panels}}
:charts [(chart/bar {:position :stack})]
:facets {:columns 4 :scales {:x :free}}
:theme {:panel {:grid {:x :none :y :none}}}
:labels {:x "Freq" :y nil}}
{:width 900 :height 350})
38.2.10 Fig 2.10 Vertical grid lines
Source: Lattice Fig 2.10. Data: Titanic passengers and crew by class, sex, age and survival, R datasets package Titanic (Dawson 1995); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data titanic
:mapping {:x :n :y :class :color :survived :facet #(str (:age %) " " (:sex %))}
:scales {:facet {:domain titanic-panels}}
:charts [(chart/bar {:position :stack})]
:facets {:columns 4 :scales {:x :free}}
:theme {:panel {:grid {:y :none}}}
:labels {:x "Freq" :y nil}}
{:width 900 :height 350})
38.2.11 Fig 2.11 Bars without borders
Source: Lattice Fig 2.11. Data: Titanic passengers and crew by class, sex, age and survival, R datasets package Titanic (Dawson 1995); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data titanic
:mapping {:x :n :y :class :color :survived :facet #(str (:age %) " " (:sex %))}
:scales {:facet {:domain titanic-panels}}
:charts [(chart/bar {:position :stack :stroke-color :none})]
:facets {:columns 4 :scales {:x :free}}
:theme {:panel {:grid {:x :none :y :none}}}
:labels {:x "Freq" :y nil}}
{:width 900 :height 350})
38.3 Chapter 3 - Visualizing Univariate Distributions
38.3.1 Fig 3.1 Kernel density
Old Faithful eruption times: a Gaussian kernel density, the values as jittered points along the bottom edge.
Source: Lattice Fig 3.1. Data: Old Faithful geyser eruptions, R datasets package faithful (Härdle 1991; Azzalini & Bowman 1990); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data faithful
:mapping {:x :eruptions}
:charts [(chart/density) (chart/stripplot {:place :edge :thickness 16 :rng (r/rng :mersenne 31)})]
:labels {:x "eruptions" :y "Density"}}
{:width 600 :height 450})
38.3.2 Fig 3.2 Rectangular kernel
A rectangular kernel of standard deviation 0.2 (R’s bw) - half-width 0.2 √3 - at 200 points.
Source: Lattice Fig 3.2. Data: Old Faithful geyser eruptions, R datasets package faithful (Härdle 1991; Azzalini & Bowman 1990); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data faithful
:mapping {:x :eruptions}
:charts [(chart/density {:kernel :uniform :bandwidth (* 0.2 (m/sqrt 3.0)) :n 200}) (chart/rug {:thickness 16})]
:labels {:x "eruptions" :y "Density"}}
{:width 600 :height 450})
38.3.3 Fig 3.3 Densities by day
Flow cytometry of a graft-versus-host-disease patient: log forward scatter, a panel per day after transplant.
Source: Lattice Fig 3.3. Data: Flow cytometry of a GvHD patient, 10 days, R latticeExtra package gvhd10 (Brinkman et al. 2007); licence: GPL (>= 2) (latticeExtra).
(def gvhd10-log
"gvhd10 with log and log2 forward scatter."
(mapv (fn [{:keys [fsc-h] :as row}] (assoc row :log-fsc (m/log fsc-h) :log2-fsc (m/log2 fsc-h))) gvhd10))| fsc-h | log-fsc | fl2-a | log2-fsc | days | ssc-h | fl4-h | fl2-h | fl3-h | fl1-h |
|---|---|---|---|---|---|---|---|---|---|
| 548 | 6.306275286948016 | 8 | 9.098032082960527 | -6 | 536 | 2.09230797761688 | 20.0471567388252 | 1 | 1 |
| 213 | 5.3612921657094255 | 23 | 7.734709620225838 | -6 | 33 | 1 | 104.134661084393 | 7.93077699270318 | 2.13032443014118 |
| 205 | 5.3230099791384085 | 30 | 7.679480099505446 | -6 | 38 | 1 | 141.428727684403 | 5.94557070854439 | 4.11036835059307 |
| 119 | 4.77912349311153 | 148 | 6.894817763307944 | -6 | 45 | 1.2637517764381 | 630.389532491958 | 4.79018080525539 | 1.55450940125585 |
| 474 | 6.161207321695077 | 812 | 8.888743248898258 | -6 | 904 | 37.9898557212078 | 2203.47691230698 | 84.6571676104789 | 170.863410719865 |
| 198 | 5.288267030694535 | 28 | 7.6293566200796095 | -6 | 45 | 1.94690635864944 | 136.4260674966 | 1 | 1.48608281057475 |
| 267 | 5.58724865840025 | 29 | 8.060695931687555 | -6 | 177 | 7.05480231071864 | 132.790545637149 | 17.8328968037465 | 64.6192155154038 |
| 60 | 4.0943445622221 | 105 | 5.906890595608519 | -6 | 82 | 1.65563207635131 | 320.888284294226 | 1 | 3.10934291996487 |
| 69 | 4.23410650459726 | 12 | 6.108524456778169 | -6 | 8 | 2.14959090655457 | 30.8841796746407 | 1 | 1 |
| 552 | 6.313548046277095 | 5 | 9.108524456778168 | -6 | 544 | 1.96451401732681 | 18.6540114290992 | 1 | 1.05550528101563 |
| 619 | 6.428105272684596 | 65 | 9.273795599214264 | -6 | 466 | 1.00904391657007 | 12.6659945315439 | 1 | 2.62045871358794 |
| 143 | 4.962844630259907 | 54 | 7.159871336778389 | -6 | 388 | 1.38280984651361 | 108.929535084032 | 1 | 1 |
| 250 | 5.521460917862246 | 10 | 7.965784284662087 | -6 | 719 | 1 | 20.4114060704541 | 1 | 1.45956309563553 |
| 453 | 6.115892125483034 | 4 | 8.823367240046235 | -6 | 645 | 1.73186555244082 | 14.1110755578985 | 1.70095975066655 | 1 |
| 93 | 4.532599493153256 | 65 | 6.539158811108031 | -6 | 68 | 1 | 11.6801569979431 | 1.91216307161501 | 1.76333290106119 |
| 423 | 6.0473721790462776 | 469 | 8.72451385311995 | -6 | 476 | 84.6571676104789 | 1942.52915803364 | 46.7303698178921 | 251.641354213874 |
| 314 | 5.749392985908253 | 246 | 8.294620748891626 | -6 | 447 | 62.8972237079901 | 1072.26722201032 | 44.6733865115693 | 280.351468174132 |
| 149 | 5.003946305945459 | 42 | 7.219168520462161 | -6 | 190 | 7.4463810954848 | 188.65130945543 | 12.6659945315439 | 33.4908898004629 |
| 192 | 5.2574953720277815 | 65 | 7.584962500721156 | -6 | 46 | 2.57369562770885 | 288.026893303126 | 1.98228091820025 | 2.43835409826883 |
| 221 | 5.3981627015177525 | 26 | 7.787902559391432 | -6 | 82 | 1.37041591927341 | 125.807561577878 | 1.29835060413413 | 1.87803979179797 |
| 111 | 4.709530201312334 | 20 | 6.794415866350106 | -6 | 94 | 3.08147432327237 | 90.9796541404939 | 2.24856868629063 | 7.18298542715413 |
| 73 | 4.290459441148391 | 48 | 6.189824558880018 | -6 | 119 | 7.71943532136078 | 197.33774727821 | 6.74426313375284 | 44.2729853259731 |
| 150 | 5.0106352940962555 | 52 | 7.22881869049588 | -6 | 183 | 6.27558128152045 | 229.9753716788 | 8.37097699835546 | 30.0611689965592 |
| 223 | 5.407171771460119 | 278 | 7.800899899920305 | -6 | 340 | 23.5740400812209 | 1111.58660312765 | 22.134185158215 | 2263.80340952145 |
| 107 | 4.672828834461906 | 185 | 6.741466986401147 | -6 | 147 | 70.7069925872126 | 728.064889525607 | 17.2021061268172 | 236.271606752329 |
| 303 | 5.713732805509369 | 122 | 8.243173983472952 | -6 | 212 | 60.1286057902297 | 526.511212920003 | 88.5552016332685 | 715.072293695766 |
| 183 | 5.209486152841421 | 83 | 7.515699838284043 | -6 | 31 | 1.14459284406143 | 363.994498073774 | 2.94583359826773 | 1.79537199962357 |
| 126 | 4.836281906951478 | 241 | 6.977279923499917 | -6 | 156 | 41.5688804861519 | 1025.06802833418 | 51.5952796467086 | 166.310192437971 |
| 92 | 4.5217885770490405 | 39 | 6.523561956057013 | -6 | 215 | 7.31349758281927 | 117.064764949724 | 16.5936279705333 | 35.6695117922078 |
| 120 | 4.787491742782046 | 293 | 6.906890595608519 | -6 | 177 | 37.3119122464974 | 1238.40907295655 | 20.0471567388252 | 192.079033110973 |
| 100 | 4.605170185988092 | 142 | 6.643856189774724 | -6 | 180 | 21.1598798071781 | 472.592476475583 | 11.7857913633579 | 22.3343648821325 |
| 174 | 5.159055299214529 | 0 | 7.442943495848728 | -6 | 1023 | 3.52703345957657 | 6.05359950210121 | 5.63291422173031 | 9.15960684216839 |
| 284 | 5.648974238161206 | 31 | 8.149747119504681 | -6 | 98 | 49.3241521265985 | 142.707797298193 | 1 | 17.8328968037465 |
| 149 | 5.003946305945459 | 62 | 7.219168520462161 | -6 | 42 | 1 | 270.434790343611 | 1.96451401732681 | 1 |
| 684 | 6.52795791762255 | 520 | 9.417852514885897 | -6 | 781 | 119.191787895958 | 2106.48398795936 | 401.888493311026 | 199.12245340072 |
| 201 | 5.303304908059076 | 178 | 7.651051691178929 | -6 | 274 | 5.68385782799802 | 754.762582303841 | 14.8943147721724 | 59.5896816806725 |
| 166 | 5.111987788356544 | 62 | 7.3750394313469245 | -6 | 73 | 1.40793498365523 | 277.838717988706 | 1 | 3.55893165592484 |
| 147 | 4.990432586778736 | 28 | 7.199672344836364 | -6 | 178 | 6.21933414241503 | 124.679966364121 | 10.3900536674351 | 32.3062398088944 |
| 263 | 5.572154032177765 | 22 | 8.038918989292302 | -6 | 68 | 1 | 106.02674888485 | 1 | 5.24146379659874 |
| 109 | 4.6913478822291435 | 60 | 6.768184324776926 | -6 | 220 | 8.75641811414753 | 256.213583397131 | 9.93270297603253 | 39.3829204209698 |
| 89 | 4.48863636973214 | 41 | 6.475733430966398 | -6 | 147 | 7.4463810954848 | 185.284754836759 | 6.80525768686113 | 30.333039700963 |
| 184 | 5.214935757608986 | 12 | 7.523561956057013 | -6 | 56 | 1.64079288241399 | 69.4451993181706 | 1.37041591927341 | 3.49542116220829 |
| 424 | 6.049733455231958 | 202 | 8.727920454563199 | -6 | 479 | 13.1304487795084 | 818.466630350764 | 34.0994067280454 | 60.1286057902297 |
| 176 | 5.170483995038151 | 67 | 7.459431618637297 | -6 | 327 | 4.33851550097049 | 290.631784496097 | 12.4399650249727 | 26.2636352765333 |
| 166 | 5.111987788356544 | 102 | 7.3750394313469245 | -6 | 210 | 7.24794774808137 | 428.031815121024 | 12.3284673944207 | 56.9666555645962 |
| 117 | 4.762173934797756 | 28 | 6.870364719583405 | -6 | 36 | 1.40793498365523 | 133.991492253186 | 1 | 3.43304403749179 |
| 69 | 4.23410650459726 | 41 | 6.108524456778169 | -6 | 144 | 3.59111833689962 | 129.251904230482 | 8.91551895259033 | 19.8674769349675 |
| 149 | 5.003946305945459 | 137 | 7.219168520462161 | -6 | 320 | 40.8270679485257 | 536.077724515626 | 19.6894075755402 | 2809.83198521168 |
| 752 | 6.62273632394984 | 466 | 9.554588851677638 | -6 | 610 | 149.278768958209 | 1840.37843578054 | 447.740513454224 | 251.641354213874 |
| 442 | 6.091309882077698 | 145 | 8.787902559391432 | -6 | 499 | 43.8761728790409 | 531.27293640286 | 146.614832351797 | 373.95989092699 |
| 96 | 4.564348191467836 | 43 | 6.584962500721156 | -6 | 168 | 5.19448530487696 | 173.967934915758 | 10.2046391942289 | 21.739192176242 |
| 209 | 5.342334251964811 | 98 | 7.7073591320808825 | -6 | 46 | 1.37041591927341 | 424.195427069203 | 2.20844211988575 | 1.79537199962357 |
| 214 | 5.365976015021851 | 27 | 7.741466986401147 | -6 | 50 | 1.15494444624982 | 130.420847668866 | 3.52703345957657 | 3.59111833689962 |
| 733 | 6.597145701886651 | 247 | 9.517669388133811 | -6 | 407 | 167.814287943133 | 1034.33865806109 | 223.846920524153 | 1283.82077380798 |
| 201 | 5.303304908059076 | 68 | 7.651051691178929 | -6 | 34 | 1.35813307703366 | 304.013906955975 | 4.00083404924448 | 1.79537199962357 |
| 97 | 4.574710978503383 | 25 | 6.599912842187128 | -6 | 125 | 2.79092265216635 | 108.929535084032 | 6.50570299658905 | 11.0659389469887 |
| 376 | 5.929589143389895 | 173 | 8.554588851677638 | -6 | 332 | 62.8972237079901 | 734.649447644077 | 229.9753716788 | 136.4260674966 |
| 214 | 5.365976015021851 | 8 | 7.741466986401147 | -6 | 72 | 1.98228091820025 | 48.4439438066395 | 3.13746355792078 | 2.66807146722781 |
| 135 | 4.90527477843843 | 66 | 7.076815597050831 | -6 | 175 | 9.75545010046874 | 260.868888272656 | 14.1110755578985 | 73.2997746215121 |
| 391 | 5.968707559985366 | 145 | 8.611024797307353 | -6 | 226 | 22.5363550147721 | 489.922152618146 | 14.1110755578985 | 70.7069925872126 |
| 74 | 4.30406509320417 | 36 | 6.20945336562895 | -6 | 113 | 4.87721659688546 | 145.300744540603 | 3.16583851658026 | 26.7408356955381 |
| 298 | 5.697093486505405 | 104 | 8.219168520462162 | -6 | 72 | 2.18864816844905 | 439.750413105138 | 1.17592935438895 | 8.52307451604617 |
| 227 | 5.424950017481403 | 17 | 7.826548487290915 | -6 | 63 | 1.10410595610039 | 87.7614940034364 | 1.79537199962357 | 4.2610930359999 |
| 193 | 5.262690188904886 | 11 | 7.592457037268081 | -6 | 79 | 1.86120718925869 | 48.4439438066395 | 8.22159371891811 | 12.3284673944207 |
| 109 | 4.6913478822291435 | 303 | 6.768184324776926 | -6 | 197 | 58.5262810678365 | 1238.40907295655 | 22.9458321470371 | 265.608778294669 |
| 90 | 4.499809670330265 | 38 | 6.491853096329675 | -6 | 51 | 1 | 163.34232357928 | 1.09421001204135 | 1.3338966739233 |
| 379 | 5.937536205082426 | 130 | 8.566054038171092 | -6 | 288 | 63.4660609516945 | 555.735365751008 | 227.914135254419 | 60.6724038844714 |
| 66 | 4.189654742026425 | 80 | 6.044394119358453 | -6 | 167 | 3.37178005637296 | 142.707797298193 | 10.2046391942289 | 12.6659945315439 |
| 250 | 5.521460917862246 | 115 | 7.965784284662087 | -6 | 482 | 12.3284673944207 | 526.511212920003 | 1.59706855245047 | 7842.02373630883 |
| 105 | 4.653960350157523 | 34 | 6.714245517666122 | -6 | 127 | 3.40227415389544 | 151.991108295293 | 8.4466834159386 | 20.4114060704541 |
| 116 | 4.7535901911063645 | 26 | 6.857980995127572 | -6 | 199 | 11.0659389469887 | 111.911793376878 | 10.7710505603677 | 145.300744540603 |
| 95 | 4.553876891600541 | 32 | 6.569855608330948 | -6 | 109 | 4.49760620239682 | 138.904878060602 | 9.24244556226364 | 12.6659945315439 |
| 190 | 5.247024072160486 | 484 | 7.569855608330948 | -6 | 380 | 64.6192155154038 | 1823.88338659859 | 21.1598798071781 | 3394.6248715068 |
| 206 | 5.327876168789581 | 53 | 7.6865005271832185 | -6 | 52 | 1.05550528101563 | 238.408427451674 | 1.19729555045153 | 2.35210389174505 |
| 221 | 5.3981627015177525 | 228 | 7.787902559391432 | -6 | 416 | 60.1286057902297 | 945.283489164419 | 24.4384856666141 | 6609.01674756612 |
| 273 | 5.60947179518496 | 50 | 8.092757140919852 | -6 | 145 | 65.2036263093488 | 221.840612532554 | 92.6327203904486 | 60.6724038844714 |
| 122 | 4.804021044733257 | 111 | 6.930737337562887 | -6 | 192 | 46.3115321845825 | 443.727479152916 | 8.91551895259033 | 82.4011985786459 |
| 101 | 4.61512051684126 | 275 | 6.658211482751795 | -6 | 184 | 26.2636352765333 | 1111.58660312765 | 26.2636352765333 | 1152.34780182525 |
| 249 | 5.517452896464707 | 138 | 7.960001932068081 | -6 | 89 | 1.65563207635131 | 586.581613397342 | 1.13433402180562 | 2.16903162737324 |
| 215 | 5.3706380281276624 | 26 | 7.7481928495894605 | -6 | 57 | 1 | 124.679966364121 | 3.40227415389544 | 2.69220128298041 |
| 429 | 6.061456918928017 | 152 | 8.744833837499545 | -6 | 400 | 46.7303698178921 | 526.511212920003 | 217.881782133305 | 84.6571676104789 |
| 375 | 5.926926025970411 | 119 | 8.550746785383243 | -6 | 392 | 68.8227719108873 | 503.335176013196 | 151.991108295293 | 351.119173421513 |
| 132 | 4.882801922586371 | 28 | 7.044394119358453 | -6 | 326 | 10.2046391942289 | 143.998434710856 | 1.32194114846603 | 3187.28801638324 |
| 202 | 5.308267697401205 | 34 | 7.658211482751795 | -6 | 39 | 1 | 158.98952943339 | 4.49760620239682 | 3.43304403749179 |
| 236 | 5.4638318050256105 | 304 | 7.882643049361842 | -6 | 286 | 30.8841796746407 | 1205.40758476377 | 47.5794431400941 | 167.814287943133 |
| 396 | 5.981414211254481 | 225 | 8.62935662007961 | -6 | 208 | 70.7069925872126 | 920.093297500199 | 247.150718205448 | 27.9721158137042 |
| 213 | 5.3612921657094255 | 28 | 7.734709620225838 | -6 | 53 | 1.37041591927341 | 135.203300130224 | 1 | 2.94583359826773 |
| 212 | 5.356586274672012 | 84 | 7.727920454563199 | -6 | 347 | 4.83350280081368 | 351.119173421513 | 13.9846000022126 | 65.7933224657568 |
| 181 | 5.198497031265826 | 188 | 7.499845887083206 | -6 | 354 | 84.6571676104789 | 734.649447644077 | 8.00250227816105 | 2346.81569154085 |
| 187 | 5.231108616854587 | 99 | 7.546894459887636 | -6 | 66 | 1 | 424.195427069203 | 1.28671367302571 | 5.68385782799802 |
| 587 | 6.375024819828097 | 373 | 9.197216693110052 | -6 | 494 | 86.9749002617783 | 1593.47788697228 | 238.408427451674 | 268.010921925845 |
| 84 | 4.430816798843313 | 31 | 6.392317422778761 | -6 | 136 | 5.43366505800142 | 130.420847668866 | 8.99615016217647 | 33.7937786136758 |
| 133 | 4.890349128221754 | 343 | 7.05528243550119 | -6 | 75 | 1.12416714790911 | 1430.29368099655 | 6.33233711505923 | 2.09230797761688 |
| 339 | 5.82600010738045 | 213 | 8.405141463136344 | -6 | 251 | 71.9917121674961 | 928.414544519474 | 219.852286793058 | 122.455004778482 |
| 212 | 5.356586274672012 | 5 | 7.727920454563199 | -6 | 61 | 1.28671367302571 | 36.64606693184 | 2.22841508616783 | 3.75647115760237 |
| 358 | 5.8805329864007 | 198 | 8.483815777264256 | -6 | 371 | 57.4818572447986 | 833.337862563382 | 208.291034395878 | 104.134661084393 |
| 68 | 4.219507705176107 | 40 | 6.087462841250339 | -6 | 153 | 16.1514361055807 | 160.427417473101 | 13.9846000022126 | 111.911793376878 |
| 195 | 5.272999558563747 | 41 | 7.60733031374961 | -6 | 155 | 47.5794431400941 | 192.079033110973 | 99.5508484525876 | 39.0299369276608 |
| 356 | 5.87493073085203 | 133 | 8.475733430966399 | -6 | 172 | 56.9666555645962 | 576.113840629102 | 158.98952943339 | 183.624074030966 |
| 240 | 5.480638923341991 | 100 | 7.906890595608519 | -6 | 384 | 9.41037733745403 | 394.716639761467 | 23.1533523386059 | 56.4560715635018 |
| … | … | … | … | … | … | … | … | … | … |
(plot/render-image
{:data gvhd10-log
:mapping {:x :log-fsc :facet :days}
:charts [(chart/density)]
:facets {:columns 2}
:labels {:x "log(FSC.H)" :y "Density"}}
{:width 700 :height 750})
38.3.4 Fig 3.4 Histograms on the density scale
Source: Lattice Fig 3.4. Data: Flow cytometry of a GvHD patient, 10 days, R latticeExtra package gvhd10 (Brinkman et al. 2007); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
{:data gvhd10-log
:mapping {:x :log2-fsc :facet :days}
:charts [(chart/histogram {:bins 50 :y :density})]
:facets {:columns 2}
:labels {:x "log Forward Scatter" :y "Density"}}
{:width 700 :height 750})
38.3.5 Fig 3.5 Normal Q-Q plots
GCSE score quantiles against the standard normal, a panel per A-level score.
Source: Lattice Fig 3.5. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97
:mapping {:y :gcsescore :facet :score}
:charts [(chart/qq {:x-distribution [:normal] :size 2 :line false})]
:facets {:columns 3}
:labels {:x "qnorm" :y "gcsescore"}}
{:width 800 :height 500})
38.3.6 Fig 3.6 Grouped Q-Q plots
Source: Lattice Fig 3.6. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97
:mapping {:y :gcsescore :color :score :facet :gender}
:scales {:color {:type :categorical}}
:charts [(chart/qq {:x-distribution [:normal] :size 3 :line false})]
:facets {:columns 2}
:labels {:x "Standard Normal Quantiles" :y "Average GCSE Score"}}
{:width 800 :height 450})
38.3.7 Fig 3.7 A power transformation
GCSE score to the power 2.34 makes the score groups’ quantile curves nearly straight and parallel.
Source: Lattice Fig 3.7. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(def chem97-trans
"chem97 with the transformed GCSE score `gcsescore^2.34`."
(mapv #(assoc % :gcsescore-trans (m/pow (:gcsescore %) 2.34)) chem97))| lea | age | school | gcsescore | score | gcsecnt | gender | student | gcsescore-trans |
|---|---|---|---|---|---|---|---|---|
| 1 | 3 | 1 | 6.625 | 4 | 0.33931571143033 | F | 1 | 83.47856315228054 |
| 1 | -3 | 1 | 7.625 | 10 | 1.33931571143033 | F | 2 | 115.9955275355124 |
| 1 | -4 | 1 | 7.25 | 10 | 0.96431571143033 | F | 3 | 103.08392240919011 |
| 1 | -2 | 1 | 7.5 | 10 | 1.21431571143033 | F | 4 | 111.59464535084454 |
| 1 | -1 | 1 | 6.444 | 8 | 0.15831571143033 | F | 5 | 78.23911770109348 |
| 1 | 4 | 1 | 7.75 | 10 | 1.46431571143033 | F | 6 | 120.49415595726816 |
| 1 | 1 | 1 | 6.75 | 6 | 0.46431571143033 | F | 7 | 87.21091206357946 |
| 1 | 4 | 1 | 6.909 | 8 | 0.62331571143033 | F | 8 | 92.09404546555301 |
| 1 | 3 | 1 | 6.375 | 4 | 0.0893157114303298 | F | 9 | 76.29281552997591 |
| 1 | 0 | 1 | 7.75 | 10 | 1.46431571143033 | F | 10 | 120.49415595726816 |
| 1 | -1 | 1 | 7.857 | 10 | 1.57131571143033 | F | 11 | 124.42303833944976 |
| 1 | 1 | 1 | 7.333 | 8 | 1.04731571143033 | F | 12 | 105.86664322952748 |
| 1 | 1 | 1 | 7.75 | 10 | 1.46431571143033 | F | 13 | 120.49415595726816 |
| 1 | 0 | 2 | 7.7 | 10 | 1.41431571143033 | M | 14 | 118.68294022766867 |
| 1 | -4 | 2 | 6.3 | 10 | 0.0143157114303296 | M | 15 | 74.20905235682363 |
| 1 | 5 | 2 | 7.3 | 10 | 1.01431571143033 | M | 16 | 104.75517644121511 |
| 1 | -3 | 2 | 6.636 | 8 | 0.35031571143033 | M | 17 | 83.80326187456527 |
| 1 | 4 | 2 | 7.272 | 10 | 0.98631571143033 | M | 18 | 103.81737802670412 |
| 1 | 0 | 2 | 7.2 | 10 | 0.91431571143033 | M | 19 | 101.42804196382946 |
| 1 | -3 | 2 | 6.454 | 4 | 0.16831571143033 | M | 20 | 78.52352167627016 |
| 1 | 4 | 2 | 6.818 | 6 | 0.532315711430329 | M | 21 | 89.2806560195084 |
| 1 | -5 | 2 | 7.3 | 10 | 1.01431571143033 | M | 22 | 104.75517644121511 |
| 1 | -1 | 2 | 6.2 | 2 | -0.08568428856967 | M | 23 | 71.48197667150599 |
| 1 | -2 | 2 | 7.111 | 10 | 0.82531571143033 | M | 24 | 98.51849936039403 |
| 1 | 2 | 2 | 6.8 | 10 | 0.51431571143033 | M | 25 | 88.73007645501613 |
| 1 | -4 | 2 | 6.5 | 8 | 0.21431571143033 | M | 26 | 79.8393981640781 |
| 1 | -5 | 2 | 6.727 | 10 | 0.44131571143033 | M | 27 | 86.51713726294737 |
| 1 | -6 | 2 | 7 | 6 | 0.71431571143033 | M | 28 | 94.95753092852235 |
| 1 | -2 | 2 | 7.7 | 10 | 1.41431571143033 | M | 29 | 118.68294022766867 |
| 1 | 3 | 2 | 7.3 | 10 | 1.01431571143033 | M | 30 | 104.75517644121511 |
| 1 | 3 | 2 | 6.4 | 8 | 0.11431571143033 | M | 31 | 76.99475460001675 |
| 1 | 2 | 2 | 6.833 | 10 | 0.54731571143033 | M | 32 | 89.74096277366353 |
| 1 | 2 | 2 | 7.363 | 10 | 1.07731571143033 | M | 33 | 106.88290106571097 |
| 1 | 5 | 2 | 6.6 | 4 | 0.314315711430329 | M | 34 | 82.74329458229602 |
| 1 | -1 | 2 | 7.6 | 10 | 1.31431571143033 | M | 35 | 115.10754884348127 |
| 1 | -2 | 2 | 7.555 | 10 | 1.26931571143033 | M | 36 | 113.51902613244617 |
| 1 | 0 | 2 | 7.7 | 10 | 1.41431571143033 | M | 37 | 118.68294022766867 |
| 1 | -5 | 2 | 7.7 | 10 | 1.41431571143033 | M | 38 | 118.68294022766867 |
| 1 | -5 | 2 | 6 | 8 | -0.28568428856967 | M | 39 | 66.20242925692598 |
| 1 | 3 | 2 | 8 | 10 | 1.71431571143033 | M | 40 | 129.7868134131237 |
| 1 | -6 | 2 | 6.6 | 10 | 0.314315711430329 | M | 41 | 82.74329458229602 |
| 2 | 3 | 3 | 6.555 | 8 | 0.26931571143033 | F | 42 | 81.4291888639809 |
| 2 | -1 | 3 | 4.75 | 0 | -1.53568428856967 | F | 43 | 38.323313027007245 |
| 2 | 0 | 3 | 4.625 | 6 | -1.66068428856967 | M | 44 | 36.00488803743606 |
| 2 | 0 | 4 | 5.25 | 6 | -1.03568428856967 | M | 45 | 48.43650181700352 |
| 2 | 5 | 4 | 6 | 10 | -0.28568428856967 | M | 46 | 66.20242925692598 |
| 2 | -3 | 4 | 6.375 | 10 | 0.0893157114303298 | M | 47 | 76.29281552997591 |
| 2 | 1 | 4 | 6.75 | 10 | 0.46431571143033 | M | 48 | 87.21091206357946 |
| 2 | 3 | 4 | 6 | 2 | -0.28568428856967 | M | 49 | 66.20242925692598 |
| 2 | 3 | 4 | 6.25 | 10 | -0.0356842885696702 | M | 50 | 72.8382059955927 |
| 2 | 3 | 4 | 7 | 10 | 0.71431571143033 | F | 51 | 94.95753092852235 |
| 2 | 5 | 5 | 6.25 | 8 | -0.0356842885696702 | M | 52 | 72.8382059955927 |
| 2 | 3 | 5 | 4.285 | 0 | -2.00068428856967 | F | 53 | 30.113756435807495 |
| 2 | -2 | 5 | 6.75 | 6 | 0.46431571143033 | M | 54 | 87.21091206357946 |
| 2 | 4 | 5 | 6.375 | 4 | 0.0893157114303298 | M | 55 | 76.29281552997591 |
| 2 | -2 | 5 | 6.777 | 6 | 0.49131571143033 | M | 56 | 88.02939485987078 |
| 2 | 0 | 5 | 7.125 | 8 | 0.83931571143033 | F | 57 | 98.97296768898418 |
| 2 | -3 | 5 | 6.285 | 6 | -6.84288569670066E-4 | F | 58 | 73.79626129610361 |
| 2 | -4 | 5 | 7.25 | 8 | 0.96431571143033 | M | 59 | 103.08392240919011 |
| 2 | -5 | 5 | 5.25 | 2 | -1.03568428856967 | M | 60 | 48.43650181700352 |
| 2 | 4 | 5 | 5.8 | 8 | -0.48568428856967 | F | 61 | 61.153526312713964 |
| 2 | 5 | 5 | 6 | 6 | -0.28568428856967 | F | 62 | 66.20242925692598 |
| 2 | -1 | 5 | 5.75 | 4 | -0.53568428856967 | F | 63 | 59.92703028939093 |
| 2 | 4 | 5 | 6.875 | 8 | 0.58931571143033 | M | 64 | 91.03703902087197 |
| 2 | 5 | 5 | 5.75 | 6 | -0.53568428856967 | M | 65 | 59.92703028939093 |
| 2 | -3 | 5 | 5.142 | 2 | -1.14368428856967 | M | 66 | 46.13696786874445 |
| 2 | 2 | 5 | 7.125 | 6 | 0.83931571143033 | F | 67 | 98.97296768898418 |
| 2 | 2 | 6 | 8 | 10 | 1.71431571143033 | F | 68 | 129.7868134131237 |
| 2 | 0 | 6 | 7 | 4 | 0.71431571143033 | F | 69 | 94.95753092852235 |
| 2 | 3 | 6 | 5.777 | 4 | -0.50868428856967 | F | 70 | 60.58757077463065 |
| 2 | -2 | 6 | 7 | 2 | 0.71431571143033 | F | 71 | 94.95753092852235 |
| 2 | -1 | 6 | 5.666 | 2 | -0.61968428856967 | F | 72 | 57.89848157599775 |
| 2 | 0 | 6 | 6.5 | 2 | 0.21431571143033 | M | 73 | 79.8393981640781 |
| 2 | 1 | 6 | 7.875 | 10 | 1.58931571143033 | F | 74 | 125.09107252609782 |
| 2 | -5 | 6 | 7.666 | 10 | 1.38031571143033 | F | 75 | 117.46027868454017 |
| 2 | 1 | 6 | 6.888 | 0 | 0.60231571143033 | M | 76 | 91.44036352839332 |
| 2 | 0 | 6 | 6.555 | 8 | 0.26931571143033 | F | 77 | 81.4291888639809 |
| 2 | 2 | 6 | 5.666 | 0 | -0.61968428856967 | F | 78 | 57.89848157599775 |
| 2 | 0 | 6 | 6.5 | 8 | 0.21431571143033 | M | 79 | 79.8393981640781 |
| 2 | -4 | 6 | 5.777 | 2 | -0.50868428856967 | F | 80 | 60.58757077463065 |
| 2 | 4 | 6 | 7 | 4 | 0.71431571143033 | F | 81 | 94.95753092852235 |
| 2 | -5 | 7 | 5.2 | 4 | -1.08568428856967 | F | 82 | 47.36394019852429 |
| 2 | -3 | 7 | 5 | 0 | -1.28568428856967 | F | 83 | 43.21055158573641 |
| 2 | 5 | 7 | 6.777 | 4 | 0.49131571143033 | F | 84 | 88.02939485987078 |
| 2 | 1 | 7 | 4.555 | 0 | -1.73068428856967 | F | 85 | 34.742639682060684 |
| 2 | 0 | 8 | 7.111 | 10 | 0.82531571143033 | F | 86 | 98.51849936039403 |
| 2 | -1 | 8 | 5.285 | 4 | -1.00068428856967 | M | 87 | 49.195488848038416 |
| 2 | -6 | 8 | 7 | 8 | 0.71431571143033 | F | 88 | 94.95753092852235 |
| 2 | 0 | 8 | 5.8 | 6 | -0.48568428856967 | M | 89 | 61.153526312713964 |
| 2 | 2 | 8 | 7.111 | 10 | 0.82531571143033 | F | 90 | 98.51849936039403 |
| 2 | -3 | 8 | 5.555 | 8 | -0.73068428856967 | F | 91 | 55.2790674660469 |
| 2 | -2 | 8 | 5.6 | 6 | -0.685684288569671 | F | 92 | 56.332624239665506 |
| 2 | 5 | 8 | 5.714 | 4 | -0.57168428856967 | M | 93 | 59.05275346346138 |
| 2 | -3 | 8 | 6.875 | 8 | 0.58931571143033 | F | 94 | 91.03703902087197 |
| 2 | 5 | 8 | 5 | 8 | -1.28568428856967 | M | 95 | 43.21055158573641 |
| 2 | -1 | 8 | 6.375 | 6 | 0.0893157114303298 | F | 96 | 76.29281552997591 |
| 2 | -2 | 9 | 6.875 | 10 | 0.58931571143033 | M | 97 | 91.03703902087197 |
| 2 | -1 | 9 | 5.875 | 6 | -0.41068428856967 | M | 98 | 63.0200027818032 |
| 2 | -5 | 9 | 8 | 10 | 1.71431571143033 | M | 99 | 129.7868134131237 |
| 2 | 2 | 9 | 6.625 | 10 | 0.33931571143033 | F | 100 | 83.47856315228054 |
| … | … | … | … | … | … | … | … | … |
(plot/render-image
{:data chem97-trans
:mapping {:y :gcsescore-trans :color :score :facet :gender}
:scales {:color {:type :categorical :title "score"}}
:charts [(chart/qq {:x-distribution [:normal] :size 3 :line false})]
:facets {:columns 2}
:labels {:x "Standard Normal Quantiles" :y "Transformed GCSE Score"}}
{:width 800 :height 450})
38.3.8 Fig 3.8 Empirical CDFs
Source: Lattice Fig 3.8. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(def chem97-positive (filterv #(pos? (:gcsescore %)) chem97))| lea | school | student | score | gender | age | gcsescore | gcsecnt |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 4 | F | 3 | 6.625 | 0.33931571143033 |
| 1 | 1 | 2 | 10 | F | -3 | 7.625 | 1.33931571143033 |
| 1 | 1 | 3 | 10 | F | -4 | 7.25 | 0.96431571143033 |
| 1 | 1 | 4 | 10 | F | -2 | 7.5 | 1.21431571143033 |
| 1 | 1 | 5 | 8 | F | -1 | 6.444 | 0.15831571143033 |
| 1 | 1 | 6 | 10 | F | 4 | 7.75 | 1.46431571143033 |
| 1 | 1 | 7 | 6 | F | 1 | 6.75 | 0.46431571143033 |
| 1 | 1 | 8 | 8 | F | 4 | 6.909 | 0.62331571143033 |
| 1 | 1 | 9 | 4 | F | 3 | 6.375 | 0.0893157114303298 |
| 1 | 1 | 10 | 10 | F | 0 | 7.75 | 1.46431571143033 |
| 1 | 1 | 11 | 10 | F | -1 | 7.857 | 1.57131571143033 |
| 1 | 1 | 12 | 8 | F | 1 | 7.333 | 1.04731571143033 |
| 1 | 1 | 13 | 10 | F | 1 | 7.75 | 1.46431571143033 |
| 1 | 2 | 14 | 10 | M | 0 | 7.7 | 1.41431571143033 |
| 1 | 2 | 15 | 10 | M | -4 | 6.3 | 0.0143157114303296 |
| 1 | 2 | 16 | 10 | M | 5 | 7.3 | 1.01431571143033 |
| 1 | 2 | 17 | 8 | M | -3 | 6.636 | 0.35031571143033 |
| 1 | 2 | 18 | 10 | M | 4 | 7.272 | 0.98631571143033 |
| 1 | 2 | 19 | 10 | M | 0 | 7.2 | 0.91431571143033 |
| 1 | 2 | 20 | 4 | M | -3 | 6.454 | 0.16831571143033 |
| 1 | 2 | 21 | 6 | M | 4 | 6.818 | 0.532315711430329 |
| 1 | 2 | 22 | 10 | M | -5 | 7.3 | 1.01431571143033 |
| 1 | 2 | 23 | 2 | M | -1 | 6.2 | -0.08568428856967 |
| 1 | 2 | 24 | 10 | M | -2 | 7.111 | 0.82531571143033 |
| 1 | 2 | 25 | 10 | M | 2 | 6.8 | 0.51431571143033 |
| 1 | 2 | 26 | 8 | M | -4 | 6.5 | 0.21431571143033 |
| 1 | 2 | 27 | 10 | M | -5 | 6.727 | 0.44131571143033 |
| 1 | 2 | 28 | 6 | M | -6 | 7 | 0.71431571143033 |
| 1 | 2 | 29 | 10 | M | -2 | 7.7 | 1.41431571143033 |
| 1 | 2 | 30 | 10 | M | 3 | 7.3 | 1.01431571143033 |
| 1 | 2 | 31 | 8 | M | 3 | 6.4 | 0.11431571143033 |
| 1 | 2 | 32 | 10 | M | 2 | 6.833 | 0.54731571143033 |
| 1 | 2 | 33 | 10 | M | 2 | 7.363 | 1.07731571143033 |
| 1 | 2 | 34 | 4 | M | 5 | 6.6 | 0.314315711430329 |
| 1 | 2 | 35 | 10 | M | -1 | 7.6 | 1.31431571143033 |
| 1 | 2 | 36 | 10 | M | -2 | 7.555 | 1.26931571143033 |
| 1 | 2 | 37 | 10 | M | 0 | 7.7 | 1.41431571143033 |
| 1 | 2 | 38 | 10 | M | -5 | 7.7 | 1.41431571143033 |
| 1 | 2 | 39 | 8 | M | -5 | 6 | -0.28568428856967 |
| 1 | 2 | 40 | 10 | M | 3 | 8 | 1.71431571143033 |
| 1 | 2 | 41 | 10 | M | -6 | 6.6 | 0.314315711430329 |
| 2 | 3 | 42 | 8 | F | 3 | 6.555 | 0.26931571143033 |
| 2 | 3 | 43 | 0 | F | -1 | 4.75 | -1.53568428856967 |
| 2 | 3 | 44 | 6 | M | 0 | 4.625 | -1.66068428856967 |
| 2 | 4 | 45 | 6 | M | 0 | 5.25 | -1.03568428856967 |
| 2 | 4 | 46 | 10 | M | 5 | 6 | -0.28568428856967 |
| 2 | 4 | 47 | 10 | M | -3 | 6.375 | 0.0893157114303298 |
| 2 | 4 | 48 | 10 | M | 1 | 6.75 | 0.46431571143033 |
| 2 | 4 | 49 | 2 | M | 3 | 6 | -0.28568428856967 |
| 2 | 4 | 50 | 10 | M | 3 | 6.25 | -0.0356842885696702 |
| 2 | 4 | 51 | 10 | F | 3 | 7 | 0.71431571143033 |
| 2 | 5 | 52 | 8 | M | 5 | 6.25 | -0.0356842885696702 |
| 2 | 5 | 53 | 0 | F | 3 | 4.285 | -2.00068428856967 |
| 2 | 5 | 54 | 6 | M | -2 | 6.75 | 0.46431571143033 |
| 2 | 5 | 55 | 4 | M | 4 | 6.375 | 0.0893157114303298 |
| 2 | 5 | 56 | 6 | M | -2 | 6.777 | 0.49131571143033 |
| 2 | 5 | 57 | 8 | F | 0 | 7.125 | 0.83931571143033 |
| 2 | 5 | 58 | 6 | F | -3 | 6.285 | -6.84288569670066E-4 |
| 2 | 5 | 59 | 8 | M | -4 | 7.25 | 0.96431571143033 |
| 2 | 5 | 60 | 2 | M | -5 | 5.25 | -1.03568428856967 |
| 2 | 5 | 61 | 8 | F | 4 | 5.8 | -0.48568428856967 |
| 2 | 5 | 62 | 6 | F | 5 | 6 | -0.28568428856967 |
| 2 | 5 | 63 | 4 | F | -1 | 5.75 | -0.53568428856967 |
| 2 | 5 | 64 | 8 | M | 4 | 6.875 | 0.58931571143033 |
| 2 | 5 | 65 | 6 | M | 5 | 5.75 | -0.53568428856967 |
| 2 | 5 | 66 | 2 | M | -3 | 5.142 | -1.14368428856967 |
| 2 | 5 | 67 | 6 | F | 2 | 7.125 | 0.83931571143033 |
| 2 | 6 | 68 | 10 | F | 2 | 8 | 1.71431571143033 |
| 2 | 6 | 69 | 4 | F | 0 | 7 | 0.71431571143033 |
| 2 | 6 | 70 | 4 | F | 3 | 5.777 | -0.50868428856967 |
| 2 | 6 | 71 | 2 | F | -2 | 7 | 0.71431571143033 |
| 2 | 6 | 72 | 2 | F | -1 | 5.666 | -0.61968428856967 |
| 2 | 6 | 73 | 2 | M | 0 | 6.5 | 0.21431571143033 |
| 2 | 6 | 74 | 10 | F | 1 | 7.875 | 1.58931571143033 |
| 2 | 6 | 75 | 10 | F | -5 | 7.666 | 1.38031571143033 |
| 2 | 6 | 76 | 0 | M | 1 | 6.888 | 0.60231571143033 |
| 2 | 6 | 77 | 8 | F | 0 | 6.555 | 0.26931571143033 |
| 2 | 6 | 78 | 0 | F | 2 | 5.666 | -0.61968428856967 |
| 2 | 6 | 79 | 8 | M | 0 | 6.5 | 0.21431571143033 |
| 2 | 6 | 80 | 2 | F | -4 | 5.777 | -0.50868428856967 |
| 2 | 6 | 81 | 4 | F | 4 | 7 | 0.71431571143033 |
| 2 | 7 | 82 | 4 | F | -5 | 5.2 | -1.08568428856967 |
| 2 | 7 | 83 | 0 | F | -3 | 5 | -1.28568428856967 |
| 2 | 7 | 84 | 4 | F | 5 | 6.777 | 0.49131571143033 |
| 2 | 7 | 85 | 0 | F | 1 | 4.555 | -1.73068428856967 |
| 2 | 8 | 86 | 10 | F | 0 | 7.111 | 0.82531571143033 |
| 2 | 8 | 87 | 4 | M | -1 | 5.285 | -1.00068428856967 |
| 2 | 8 | 88 | 8 | F | -6 | 7 | 0.71431571143033 |
| 2 | 8 | 89 | 6 | M | 0 | 5.8 | -0.48568428856967 |
| 2 | 8 | 90 | 10 | F | 2 | 7.111 | 0.82531571143033 |
| 2 | 8 | 91 | 8 | F | -3 | 5.555 | -0.73068428856967 |
| 2 | 8 | 92 | 6 | F | -2 | 5.6 | -0.685684288569671 |
| 2 | 8 | 93 | 4 | M | 5 | 5.714 | -0.57168428856967 |
| 2 | 8 | 94 | 8 | F | -3 | 6.875 | 0.58931571143033 |
| 2 | 8 | 95 | 8 | M | 5 | 5 | -1.28568428856967 |
| 2 | 8 | 96 | 6 | F | -1 | 6.375 | 0.0893157114303298 |
| 2 | 9 | 97 | 10 | M | -2 | 6.875 | 0.58931571143033 |
| 2 | 9 | 98 | 6 | M | -1 | 5.875 | -0.41068428856967 |
| 2 | 9 | 99 | 10 | M | -5 | 8 | 1.71431571143033 |
| 2 | 9 | 100 | 10 | F | 2 | 6.625 | 0.33931571143033 |
| … | … | … | … | … | … | … | … |
(plot/render-image
{:data chem97-positive
:mapping {:x :gcsescore :color :gender :facet :score}
:charts [(chart/ecdf)]
:facets {:columns 3}
:labels {:x "Average GCSE Score" :y "Empirical CDF"}}
{:width 800 :height 500})
38.3.9 Fig 3.9 Uniform Q-Q plots
Quantiles against the uniform distribution: the empirical CDF with the axes swapped.
Source: Lattice Fig 3.9. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97-positive
:mapping {:y :gcsescore :color :gender :facet :score}
:charts [(chart/qq {:x-distribution [:uniform-real] :size 3 :line false})]
:facets {:columns 6}
:labels {:x "Uniform quantiles" :y "Average GCSE Score"}}
{:width 1000 :height 400})
38.3.10 Fig 3.10 Two-sample Q-Q plots
100 quantiles of the boys’ scores against the girls’, per A-level score (ppoints(100) probabilities), and the line y = x.
Source: Lattice Fig 3.10. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(let [ps (mapv #(/ (- % 0.5) 100.0) (range 1 101))
quantiles (fn [rows] (stats/quantiles (map :gcsescore rows) ps))]
(plot/render-image
{:data (for [[score rows] (group-by :score chem97)
:let [by-gender (group-by :gender rows)]
[f m] (map vector (quantiles (by-gender "F")) (quantiles (by-gender "M")))]
{:score score :f f :m m})
:mapping {:x :m :y :f :facet :score}
:charts [(chart/scatter) (chart/rule {:slope 1 :intercept 0 :color :grey})]
:facets {:columns 3}
:aspect :iso
:labels {:x "M" :y "F"}}
{:width 800 :height 600}))
38.3.11 Fig 3.11 Box plots
Source: Lattice Fig 3.11. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97
:mapping {:x :gcsescore :y (levels/categorical :score) :facet :gender}
:scales {:facet {:domain ["M" "F"]}}
:charts [(chart/box)]
:facets {:columns 2}
:labels {:x "Average GCSE Score" :y "score"}}
{:width 800 :height 450})
38.3.12 Fig 3.12 Box widths by group size
Source: Lattice Fig 3.12. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97-trans
:mapping {:x :gender :y :gcsescore-trans :facet :score}
:scales {:x {:domain ["M" "F"]}}
:charts [(chart/box {:varwidth true})]
:facets {:columns 6}
:labels {:x nil :y "Transformed GCSE score"}}
{:width 900 :height 400})
38.3.13 Fig 3.13 Box plots of many values
Source: Lattice Fig 3.13. Data: Flow cytometry of a GvHD patient, 10 days, R latticeExtra package gvhd10 (Brinkman et al. 2007); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
{:data gvhd10-log
:mapping {:x :log-fsc :y (levels/categorical :days)}
:charts [(chart/box)]
:labels {:x "log(Forward Scatter)" :y "Days Past Transplant"}}
{:width 700 :height 500})
38.3.14 Fig 3.14 Violins
Tails 3 bandwidths past the data (:cut 3, R’s density default as lattice uses it).
Source: Lattice Fig 3.14. Data: Flow cytometry of a GvHD patient, 10 days, R latticeExtra package gvhd10 (Brinkman et al. 2007); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
{:data gvhd10-log
:mapping {:x :log-fsc :y (levels/categorical :days)}
:charts [(chart/violin {:inner :none :cut 3})]
:labels {:x "log(Forward Scatter)" :y "Days Past Transplant"}}
{:width 700 :height 500})
38.3.15 Fig 3.15 Strip plot
Earthquake depth by magnitude, one strip per magnitude value.
Source: Lattice Fig 3.15. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data quakes
:mapping {:x :depth :y (levels/categorical :mag)}
:charts [(chart/stripplot {:jitter 0})]
:labels {:x "depth" :y "mag"}}
{:width 600 :height 700})
38.3.16 Fig 3.16 Jittered strips
Source: Lattice Fig 3.16. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data quakes
:mapping {:x (levels/categorical :mag) :y :depth}
:charts [(chart/stripplot {:rng (r/rng :mersenne 316)})]
:labels {:x "Magnitude (Richter)" :y "Depth (km)"}}
{:width 800 :height 450})
38.3.17 Fig 3.17 Residuals and their medians
Square roots of the absolute residuals of an additive model of barley yield (variety + year + site, least squares on dummy-coded factors), jittered by site (in R’s order), a line through each year’s medians; two contrasting colours for the years.
Source: Lattice Fig 3.17. Data: Barley yields, Minnesota 1931-1932, R lattice package barley (Immer et al. 1934; Fisher 1971; Cleveland 1993); licence: GPL (>= 2) (lattice).
(def barley-residuals
"barley with `:root-residual` - the square root of the absolute residual of the additive least-squares model of
yield on variety, year and site (dummy-coded factors)."
(let [dummies (vec (for [k [:variety :year :site], level (rest (sort (distinct (map k barley))))] [k level]))
model (regression/lm (mapv :yield barley)
(mapv (fn [row] (mapv (fn [[k level]] (if (= level (k row)) 1.0 0.0)) dummies)) barley))]
(mapv (fn [row residual] (assoc row :root-residual (m/sqrt (m/abs residual))))
barley (get-in model [:residuals :raw]))))| yield | variety | year | site | root-residual |
|---|---|---|---|---|
| 27 | Manchuria | 1931 | University Farm | 2.3167271814638384 |
| 48.86667 | Manchuria | 1931 | Waseca | 1.0284848888858868 |
| 27.43334 | Manchuria | 1931 | Morris | 2.7689741481879833 |
| 39.93333 | Manchuria | 1931 | Crookston | 1.677132721840035 |
| 32.96667 | Manchuria | 1931 | Grand Rapids | 2.8869440013042573 |
| 28.96667 | Manchuria | 1931 | Duluth | 1.1266967944689603 |
| 43.06666 | Glabron | 1931 | University Farm | 2.970127831143516 |
| 55.2 | Glabron | 1931 | Waseca | 2.348049261266315 |
| 28.76667 | Glabron | 1931 | Morris | 2.8656000535082873 |
| 38.13333 | Glabron | 1931 | Crookston | 0.9300546578920853 |
| 29.13333 | Glabron | 1931 | Grand Rapids | 1.6196696679673002 |
| 29.66667 | Glabron | 1931 | Duluth | 0.30277026494241277 |
| 35.13333 | Svansota | 1931 | University Farm | 1.9627067194735621 |
| 47.33333 | Svansota | 1931 | Waseca | 0.7813793359608768 |
| 25.76667 | Svansota | 1931 | Morris | 2.871894032399754 |
| 40.46667 | Svansota | 1931 | Crookston | 2.105285412163067 |
| 29.66667 | Svansota | 1931 | Grand Rapids | 2.473976185549627 |
| 25.7 | Svansota | 1931 | Duluth | 0.9545217825347531 |
| 39.9 | Velvet | 1931 | University Farm | 2.4362996531625574 |
| 50.23333 | Velvet | 1931 | Waseca | 0.9095174544779221 |
| 26.13333 | Velvet | 1931 | Morris | 3.2502995246592254 |
| 41.33333 | Velvet | 1931 | Crookston | 1.6172677576703072 |
| 23.03333 | Velvet | 1931 | Grand Rapids | 1.787767742185764 |
| 26.3 | Velvet | 1931 | Duluth | 1.7304460407652094 |
| 36.56666 | Trebi | 1931 | University Farm | 1.9330463436417336 |
| 63.8333 | Trebi | 1931 | Waseca | 2.8439950480500698 |
| 43.76667 | Trebi | 1931 | Morris | 0.8544055438334476 |
| 46.93333 | Trebi | 1931 | Crookston | 1.3699163599772304 |
| 29.76667 | Trebi | 1931 | Grand Rapids | 1.6738153024353255 |
| 33.93333 | Trebi | 1931 | Duluth | 1.303839586247739 |
| 43.26667 | No. 457 | 1931 | University Farm | 2.5526674283972053 |
| 58.1 | No. 457 | 1931 | Waseca | 2.4305919032202827 |
| 28.7 | No. 457 | 1931 | Morris | 3.283883676380756 |
| 45.66667 | No. 457 | 1931 | Crookston | 2.0402891951877677 |
| 32.16667 | No. 457 | 1931 | Grand Rapids | 1.7751370369636301 |
| 33.6 | No. 457 | 1931 | Duluth | 1.2326562781246062 |
| 36.6 | No. 462 | 1931 | University Farm | 0.5646984445997143 |
| 65.7667 | No. 462 | 1931 | Waseca | 3.7475218923087463 |
| 30.36667 | No. 462 | 1931 | Morris | 2.9407105717269526 |
| 48.56666 | No. 462 | 1931 | Crookston | 2.7444878089241485 |
| 24.93334 | No. 462 | 1931 | Grand Rapids | 1.900730166716637 |
| 28.1 | No. 462 | 1931 | Duluth | 1.873796991850147 |
| 32.76667 | Peatland | 1931 | University Farm | 1.5222419868952057 |
| 48.56666 | Peatland | 1931 | Waseca | 1.3996051824234836 |
| 29.86667 | Peatland | 1931 | Morris | 2.819672616930316 |
| 41.6 | Peatland | 1931 | Crookston | 1.3276966269947665 |
| 34.7 | Peatland | 1931 | Grand Rapids | 2.7112930187151205 |
| 32 | Peatland | 1931 | Duluth | 1.2594085251948004 |
| 24.66667 | No. 475 | 1931 | University Farm | 2.8280338871142705 |
| 46.76667 | No. 475 | 1931 | Waseca | 1.1573416378350243 |
| 22.6 | No. 475 | 1931 | Morris | 3.5773983097590123 |
| 44.1 | No. 475 | 1931 | Crookston | 2.58499967762731 |
| 19.7 | No. 475 | 1931 | Grand Rapids | 2.2867980161497945 |
| 33.06666 | No. 475 | 1931 | Duluth | 2.252157817146338 |
| 39.3 | Wisconsin No. 38 | 1931 | University Farm | 0.9988897169691311 |
| 58.8 | Wisconsin No. 38 | 1931 | Waseca | 1.7494442927207845 |
| 29.46667 | Wisconsin No. 38 | 1931 | Morris | 3.682993845591743 |
| 49.86667 | Wisconsin No. 38 | 1931 | Crookston | 2.194438044997689 |
| 34.46667 | Wisconsin No. 38 | 1931 | Grand Rapids | 1.3798151446238531 |
| 31.6 | Wisconsin No. 38 | 1931 | Duluth | 2.0069330249578963 |
| 26.9 | Manchuria | 1932 | University Farm | 0.39087018305319765 |
| 33.46667 | Manchuria | 1932 | Waseca | 3.004625351021329 |
| 34.36666 | Manchuria | 1932 | Morris | 2.1402213670552803 |
| 32.96667 | Manchuria | 1932 | Crookston | 1.077292671468578 |
| 22.13333 | Manchuria | 1932 | Grand Rapids | 1.6779603690194755 |
| 22.56667 | Manchuria | 1932 | Duluth | 0.4288251391884193 |
| 36.8 | Glabron | 1932 | University Farm | 2.805253048597689 |
| 37.73333 | Glabron | 1932 | Waseca | 2.576604225202888 |
| 35.13333 | Glabron | 1932 | Morris | 1.8626437304719976 |
| 26.16667 | Glabron | 1932 | Crookston | 2.7417542437887144 |
| 14.43333 | Glabron | 1932 | Grand Rapids | 2.600427817366473 |
| 25.86667 | Glabron | 1932 | Duluth | 1.2673259906853631 |
| 27.43334 | Svansota | 1932 | University Farm | 1.2110627564251204 |
| 38.5 | Svansota | 1932 | Waseca | 1.7053829481966791 |
| 35.03333 | Svansota | 1932 | Morris | 2.5166108161573213 |
| 20.63333 | Svansota | 1932 | Crookston | 3.175951510964871 |
| 16.63333 | Svansota | 1932 | Grand Rapids | 1.2642533369542581 |
| 22.23333 | Svansota | 1932 | Duluth | 0.9678137734089218 |
| 26.8 | Velvet | 1932 | University Farm | 1.360146560730371 |
| 37.4 | Velvet | 1932 | Waseca | 2.5868248233436035 |
| 38.83333 | Velvet | 1932 | Morris | 2.729468507481511 |
| 32.06666 | Velvet | 1932 | Crookston | 1.1561443104849478 |
| 32.23333 | Velvet | 1932 | Grand Rapids | 3.364272853579709 |
| 22.46667 | Velvet | 1932 | Duluth | 1.2301740391776481 |
| 29.06667 | Trebi | 1932 | University Farm | 2.433559704082342 |
| 49.2333 | Trebi | 1932 | Waseca | 1.0941877504950168 |
| 46.63333 | Trebi | 1932 | Morris | 2.985148935424608 |
| 41.83333 | Trebi | 1932 | Crookston | 1.4460692122670344 |
| 20.63333 | Trebi | 1932 | Grand Rapids | 2.5730433990380583 |
| 30.6 | Trebi | 1932 | Duluth | 0.5302053061472229 |
| 26.43334 | No. 457 | 1932 | University Farm | 2.236688102232106 |
| 42.2 | No. 457 | 1932 | Waseca | 2.162817067314447 |
| 43.53334 | No. 457 | 1932 | Morris | 3.0600479299078556 |
| 34.33333 | No. 457 | 1932 | Crookston | 1.3623929927398775 |
| 19.46667 | No. 457 | 1932 | Grand Rapids | 2.057776267398049 |
| 22.7 | No. 457 | 1932 | Duluth | 2.0164605542054757 |
| 25.56667 | No. 462 | 1932 | University Farm | 2.323790079446362 |
| 44.7 | No. 462 | 1932 | Waseca | 1.3070326443258153 |
| 47 | No. 462 | 1932 | Morris | 3.646916048754986 |
| 30.53333 | No. 462 | 1932 | Crookston | 2.277426471553667 |
| … | … | … | … | … |
(def barley-residual-plot
"The residuals jittered by site (R's order), a line through each year's medians (in site order, left to right)."
(let [by-site-year (group-by (juxt :site :year) barley-residuals)
sites (nu/levels :barley :site)
medians (for [site sites year [1931 1932]]
{:site site :year year :median (stats/median (map :root-residual (by-site-year [site year])))})]
{:data barley-residuals
:mapping {:x :site :y :root-residual :color :year}
:scales {:x {:domain sites} :color {:type :categorical :range two-colors}}
:charts [(chart/stripplot {:rng (r/rng :mersenne 317)})
(chart/line {:data medians :mapping {:y :median}})]
:labels {:x nil :y "√|Residual Barley Yield|"}}))(plot/render-image barley-residual-plot {:width 800 :height 450})
38.4 Chapter 4 - Displaying Multiway Tables
38.4.1 Fig 4.1 Dot plot of a table
Virginia death rates (1940) per 1000 by age group, a panel per population group.
Source: Lattice Fig 4.1. Data: Death rates in Virginia (1940), R datasets package VADeaths (Molyneaux et al. 1947); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data va-deaths
:mapping {:x :rate :y :age :facet :group}
:charts [(chart/scatter)]
:facets {:columns 2}
:labels {:x "Freq" :y nil}}
{:width 700 :height 450})
38.4.2 Fig 4.2 Stems from zero
Source: Lattice Fig 4.2. Data: Death rates in Virginia (1940), R datasets package VADeaths (Molyneaux et al. 1947); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data va-deaths
:mapping {:x :rate :y :age :facet :group}
:charts [(chart/segment {:xend 0}) (chart/scatter)]
:facets {:columns 1}
:labels {:title "Death Rates in Virginia - 1940" :x "Rate (per 1000)" :y nil}}
{:width 450 :height 750})
38.4.3 Fig 4.3 Groups joined
One line per population group across the age groups (the rows in age order, unsorted by rate).
Source: Lattice Fig 4.3. Data: Death rates in Virginia (1940), R datasets package VADeaths (Molyneaux et al. 1947); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data (sort-by :age va-deaths)
:mapping {:x :rate :y :age :color :group}
:charts [(chart/line {:sort false}) (chart/scatter)]
:labels {:title "Death Rates in Virginia - 1940" :x "Rate (per 1000)" :y nil}}
{:width 700 :height 450})
38.4.4 Fig 4.4 Bar charts
Source: Lattice Fig 4.4. Data: Death rates in Virginia (1940), R datasets package VADeaths (Molyneaux et al. 1947); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data va-deaths
:mapping {:x :rate :y :age :facet :group}
:charts [(chart/bar)]
:facets {:columns 1}
:labels {:title "Death Rates in Virginia - 1940" :x "Rate (per 1000)" :y nil}}
{:width 450 :height 750})
38.4.5 Fig 4.5 Proportions as stacked bars
Reasons for taking a postdoctoral position, as proportions of each field (:position :normalize), in R’s order.
Source: Lattice Fig 4.5. Data: Reasons for taking a postdoc, by field, R latticeExtra package postdoc (NSF Survey of Doctorate Recipients 1999); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
{:data postdoc
:mapping {:x :count :y :field :color :reason}
:scales {:color {:domain (nu/levels :postdoc :reason)}}
:charts [(chart/bar {:position :normalize})]
:labels {:x "Proportion" :y nil}}
{:width 900 :height 450})
38.4.6 Fig 4.6 Proportions as dot plots
Source: Lattice Fig 4.6. Data: Reasons for taking a postdoc, by field, R latticeExtra package postdoc (NSF Survey of Doctorate Recipients 1999); licence: GPL (>= 2) (latticeExtra).
(def postdoc-proportions
"postdoc counts as proportions of each field's total."
(let [totals (update-vals (group-by :field postdoc) #(reduce + (map :count %)))]
(mapv #(assoc % :proportion (/ (double (:count %)) (double (totals (:field %))))) postdoc)))| field | reason | count | proportion |
|---|---|---|---|
| Biological Sciences | Expected or Additional Training | 6404 | 0.48655219571493696 |
| Chemistry | Expected or Additional Training | 865 | 0.39606227106227104 |
| Earth, Atmospheric, and Ocean Sciences | Expected or Additional Training | 343 | 0.42293464858199753 |
| Engineering | Expected or Additional Training | 586 | 0.25975177304964536 |
| Medical Sciences | Expected or Additional Training | 205 | 0.3621908127208481 |
| Physics and Astronomy | Expected or Additional Training | 1010 | 0.482560917343526 |
| Social and Behavioral Sciences | Expected or Additional Training | 1368 | 0.43250079038887135 |
| All Postdoctorates | Expected or Additional Training | 11197 | 0.4372632483305346 |
| Biological Sciences | Work with Specific Person | 2427 | 0.1843944689256952 |
| Chemistry | Work with Specific Person | 308 | 0.14102564102564102 |
| Earth, Atmospheric, and Ocean Sciences | Work with Specific Person | 75 | 0.09247842170160296 |
| Engineering | Work with Specific Person | 464 | 0.20567375886524822 |
| Medical Sciences | Work with Specific Person | 137 | 0.2420494699646643 |
| Physics and Astronomy | Work with Specific Person | 347 | 0.1657907310081223 |
| Social and Behavioral Sciences | Work with Specific Person | 564 | 0.17831172937085046 |
| All Postdoctorates | Work with Specific Person | 4687 | 0.1830358886242043 |
| Biological Sciences | Training Outside PhD Field | 1950 | 0.14815377602188118 |
| Chemistry | Training Outside PhD Field | 292 | 0.1336996336996337 |
| Earth, Atmospheric, and Ocean Sciences | Training Outside PhD Field | 75 | 0.09247842170160296 |
| Engineering | Training Outside PhD Field | 288 | 0.1276595744680851 |
| Medical Sciences | Training Outside PhD Field | 82 | 0.14487632508833923 |
| Physics and Astronomy | Training Outside PhD Field | 175 | 0.08361204013377926 |
| Social and Behavioral Sciences | Training Outside PhD Field | 412 | 0.1302560859943092 |
| All Postdoctorates | Training Outside PhD Field | 3403 | 0.132893349474753 |
| Biological Sciences | Other Employment Not Available | 1779 | 0.13516182950919314 |
| Chemistry | Other Employment Not Available | 551 | 0.2522893772893773 |
| Earth, Atmospheric, and Ocean Sciences | Other Employment Not Available | 238 | 0.2934648581997534 |
| Engineering | Other Employment Not Available | 517 | 0.22916666666666666 |
| Medical Sciences | Other Employment Not Available | 68 | 0.12014134275618374 |
| Physics and Astronomy | Other Employment Not Available | 399 | 0.19063545150501673 |
| Social and Behavioral Sciences | Other Employment Not Available | 514 | 0.16250395194435663 |
| All Postdoctorates | Other Employment Not Available | 4406 | 0.1720623267075409 |
| Biological Sciences | Other | 602 | 0.04573772982829357 |
| Chemistry | Other | 168 | 0.07692307692307693 |
| Earth, Atmospheric, and Ocean Sciences | Other | 80 | 0.09864364981504316 |
| Engineering | Other | 401 | 0.1777482269503546 |
| Medical Sciences | Other | 74 | 0.13074204946996468 |
| Physics and Astronomy | Other | 162 | 0.07740086000955566 |
| Social and Behavioral Sciences | Other | 305 | 0.09642744230161239 |
| All Postdoctorates | Other | 1914 | 0.07474518686296716 |
(plot/render-image
{:data postdoc-proportions
:mapping {:x :proportion :y :field :facet :reason}
:charts [(chart/scatter)]
:facets {:columns 3}
:labels {:x "Proportion" :y nil}}
{:width 1000 :height 550})
38.4.7 Fig 4.7 Ordered panels and levels
Panels ordered by their median proportion, the fields within each panel by their proportion (free y scales).
Source: Lattice Fig 4.7. Data: Reasons for taking a postdoc, by field, R latticeExtra package postdoc (NSF Survey of Doctorate Recipients 1999); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
{:data postdoc-proportions
:mapping {:x :proportion :y :field :facet :reason}
:scales {:facet {:order-by #(stats/median (map :proportion %)) :descending true}
:y {:order-by #(stats/mean (map :proportion %))}}
:charts [(chart/scatter)]
:facets {:columns 1 :scales {:y :free}}
:labels {:x "Proportion" :y nil}}
{:width 600 :height 800})
38.4.8 Fig 4.8 Frequencies as spikes
How many candidates have each average GCSE score, by gender.
Source: Lattice Fig 4.8. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data (for [[[score gender] n] (frequencies (map (juxt :gcsescore :gender) chem97))]
{:gcsescore score :gender gender :freq n})
:mapping {:x :gcsescore :y :freq :facet :gender}
:charts [(chart/segment {:yend 0})]
:facets {:columns 1}
:labels {:x "Average GCSE Score" :y "Freq"}}
{:width 800 :height 500})
38.4.9 Fig 4.9 Bar chart of counts
Source: Lattice Fig 4.9. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97
:mapping {:y (levels/categorical :score) :facet :gender}
:scales {:facet {:domain ["M" "F"]}}
:charts [(chart/bar {:stat :count})]
:flip true
:facets {:columns 2}
:labels {:x "Freq" :y "score"}}
{:width 800 :height 400})
38.5 Chapter 5 - Scatter Plots and Extensions
38.5.1 Fig 5.1 Conditioning on a cut numeric variable
Earthquake epicentres off Fiji, a panel per depth interval (two equal-width intervals, levels/bin).
Source: Lattice Fig 5.1. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data (levels/bin quakes :depth {:as :depth-cut :bins 2})
:mapping {:x :long :y :lat :facet :depth-cut}
:charts [(chart/scatter {:shape \o :size 5})]
:facets {:columns 2}
:labels {:x "long" :y "lat"}}
{:width 800 :height 450})
38.5.2 Fig 5.2 Three depth intervals, isometric
Source: Lattice Fig 5.2. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data (levels/bin quakes :depth {:as :depth-cut :bins 3 :label "Depth"})
:mapping {:x :long :y :lat :facet :depth-cut}
:charts [(chart/scatter {:size 4})]
:facets {:columns 3}
:aspect :iso
:labels {:x "Longitude" :y "Latitude"}}
{:width 900 :height 450})
38.5.3 Fig 5.3 Depth as groups
Depth cut at its terciles: three groups of equal size, coloured.
Source: Lattice Fig 5.3. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data (levels/bin quakes :depth {:as :depth-cut :bins {:quantiles 3}})
:mapping {:x :long :y :lat :color :depth-cut}
:scales {:color {:title "Depth"}}
:charts [(chart/scatter {:size 4})]
:aspect :iso
:labels {:x "Longitude" :y "Latitude"}}
{:width 650 :height 650})
38.5.4 Fig 5.4 Depth as grey levels
Filled circles from dark (shallow) to light (deep); the deepest drawn first, so shallow ones stay on top.
Source: Lattice Fig 5.4. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(def quakes-by-depth
"quakes, deepest first."
(vec (sort-by :depth > quakes)))| lat | long | depth | mag | stations |
|---|---|---|---|---|
| -20.32 | 180.88 | 680 | 4.2 | 22 |
| -19.3 | 180.6 | 671 | 4.2 | 16 |
| -19.4 | 180.94 | 664 | 4.7 | 34 |
| -12.93 | 169.52 | 663 | 4.4 | 30 |
| -12.66 | 169.46 | 658 | 4.6 | 43 |
| -14.82 | 171.17 | 658 | 4.7 | 49 |
| -18.89 | 181.24 | 655 | 4.1 | 14 |
| -17.96 | 181.4 | 655 | 4.3 | 20 |
| -13.09 | 169.28 | 654 | 4.4 | 22 |
| -18.17 | 181.98 | 651 | 4.8 | 43 |
| -20.62 | 181.03 | 650 | 4.2 | 15 |
| -20.42 | 181.96 | 649 | 4 | 11 |
| -18.12 | 181.88 | 649 | 5.4 | 88 |
| -23.7 | 179.6 | 646 | 4.2 | 21 |
| -13.05 | 169.58 | 644 | 4.9 | 68 |
| -26 | 178.43 | 644 | 4.9 | 27 |
| -14.28 | 170.34 | 642 | 4.7 | 29 |
| -17.95 | 181.37 | 642 | 4 | 17 |
| -18.48 | 181.49 | 641 | 5 | 49 |
| -12.93 | 169.63 | 641 | 5.1 | 57 |
| -13.45 | 170.3 | 641 | 5.3 | 93 |
| -17.82 | 181.83 | 640 | 4.3 | 24 |
| -18.04 | 181.75 | 640 | 4.5 | 47 |
| -18.18 | 180.63 | 639 | 4.6 | 39 |
| -13.84 | 170.62 | 638 | 4.6 | 20 |
| -21.03 | 180.78 | 638 | 4 | 14 |
| -20.36 | 181.19 | 637 | 4.2 | 23 |
| -14.99 | 171.39 | 637 | 4.3 | 21 |
| -21.33 | 180.69 | 636 | 4.6 | 29 |
| -18 | 180.62 | 636 | 5 | 100 |
| -18.05 | 180.86 | 632 | 4.4 | 15 |
| -18.21 | 180.87 | 631 | 5.2 | 69 |
| -18.26 | 180.98 | 631 | 4.8 | 36 |
| -19.77 | 181.4 | 630 | 5.1 | 54 |
| -12.95 | 169.09 | 629 | 4.5 | 19 |
| -18.08 | 180.7 | 628 | 5.2 | 72 |
| -21.96 | 179.62 | 627 | 5 | 45 |
| -20.2 | 180.9 | 627 | 4.1 | 11 |
| -17.94 | 180.6 | 627 | 4.5 | 29 |
| -21.08 | 180.85 | 627 | 5.9 | 119 |
| -17.97 | 181.66 | 626 | 4.1 | 19 |
| -17.98 | 180.5 | 626 | 4.1 | 19 |
| -20.99 | 181.02 | 626 | 4.5 | 36 |
| -21.14 | 181.06 | 625 | 4.5 | 35 |
| -21.3 | 180.82 | 624 | 4.3 | 14 |
| -18.14 | 180.87 | 624 | 5.5 | 105 |
| -18.44 | 181.04 | 624 | 4.2 | 21 |
| -17.47 | 179.59 | 622 | 4.3 | 19 |
| -17.88 | 180.58 | 622 | 4.2 | 23 |
| -20.83 | 181.01 | 622 | 4.3 | 15 |
| -17.95 | 181.65 | 619 | 4.3 | 26 |
| -21.18 | 180.92 | 619 | 4.5 | 18 |
| -18.13 | 181.52 | 618 | 4.6 | 41 |
| -13.36 | 172.76 | 618 | 4.4 | 18 |
| -21.77 | 181 | 618 | 4.1 | 10 |
| -26.11 | 178.3 | 617 | 4.8 | 39 |
| -21.68 | 180.63 | 617 | 5 | 63 |
| -21.39 | 180.68 | 617 | 4.5 | 18 |
| -21.3 | 180.92 | 617 | 4.5 | 26 |
| -18.19 | 181.74 | 616 | 4.3 | 17 |
| -21.05 | 180.9 | 616 | 4.3 | 10 |
| -21.24 | 180.86 | 615 | 4.9 | 23 |
| -21.4 | 180.78 | 615 | 4.7 | 51 |
| -14.31 | 173.5 | 614 | 4.2 | 23 |
| -17.86 | 181.3 | 614 | 4 | 12 |
| -13.82 | 172.38 | 613 | 5 | 61 |
| -21.23 | 181.09 | 613 | 4.6 | 18 |
| -21.4 | 180.74 | 613 | 4.2 | 20 |
| -20.95 | 181.06 | 611 | 4.3 | 20 |
| -18.04 | 181.84 | 611 | 4.2 | 20 |
| -26.13 | 178.31 | 609 | 4.2 | 25 |
| -18.18 | 182.04 | 609 | 4.4 | 26 |
| -26.5 | 178.29 | 609 | 5 | 50 |
| -20.27 | 181.51 | 609 | 4.4 | 32 |
| -21.88 | 180.39 | 608 | 4.7 | 30 |
| -20.3 | 181.4 | 608 | 4.6 | 13 |
| -21.29 | 180.85 | 607 | 4.5 | 23 |
| -26.2 | 178.35 | 606 | 4.4 | 21 |
| -22.05 | 180.4 | 606 | 4.7 | 27 |
| -24.08 | 179.5 | 605 | 4.1 | 21 |
| -20.04 | 182.01 | 605 | 5.1 | 49 |
| -20.57 | 181.33 | 605 | 4.3 | 18 |
| -21.24 | 180.81 | 605 | 4.6 | 34 |
| -26.53 | 178.3 | 605 | 4.9 | 43 |
| -20.97 | 181.2 | 605 | 4.5 | 31 |
| -18.06 | 181.59 | 604 | 4.5 | 23 |
| -21.96 | 180.54 | 603 | 5.2 | 66 |
| -18.07 | 181.58 | 603 | 5 | 65 |
| -22.1 | 180.4 | 603 | 4.1 | 11 |
| -20.58 | 181.24 | 602 | 4.7 | 44 |
| -17.94 | 181.51 | 601 | 4 | 16 |
| -22.24 | 180.28 | 601 | 4.2 | 21 |
| -21 | 181.66 | 600 | 4.4 | 10 |
| -25.82 | 179.33 | 600 | 4.3 | 13 |
| -26.53 | 178.57 | 600 | 5 | 69 |
| -18.4 | 181.77 | 600 | 4.1 | 11 |
| -20.89 | 181.25 | 599 | 4.6 | 20 |
| -20.63 | 181.61 | 599 | 4.6 | 30 |
| -22.63 | 180.31 | 598 | 4.4 | 18 |
| -17.81 | 181.82 | 598 | 4.1 | 14 |
| … | … | … | … | … |
(def grey-depth
"Colour scale of depth: grey levels as R's `gray.colors`, dark for shallow."
{:color {:range [[77 77 77] [230 230 230]] :title "depth"}})(plot/render-image
{:data quakes-by-depth
:mapping {:x :long :y :lat :color :depth}
:scales grey-depth
:charts [(chart/scatter {:size 8 :stroke-color :black :stroke-width 0.5})]
:aspect :iso
:legend false
:labels {:x "Longitude" :y "Latitude"}}
{:width 600 :height 650})
38.5.5 Fig 5.5 Grey levels by magnitude
A panel per magnitude interval: a shingle of four equal-count, half-overlapping intervals.
Source: Lattice Fig 5.5. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(def quakes-magnitude
(shingle/shingle quakes-by-depth :mag {:count 4 :overlap 0.5 :as :magnitude :label "Magnitude"}))| lat | long | depth | mag | stations | magnitude |
|---|---|---|---|---|---|
| -20.32 | 180.88 | 680 | 4.2 | 22 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -19.3 | 180.6 | 671 | 4.2 | 16 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -19.4 | 180.94 | 664 | 4.7 | 34 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -19.4 | 180.94 | 664 | 4.7 | 34 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -19.4 | 180.94 | 664 | 4.7 | 34 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -12.93 | 169.52 | 663 | 4.4 | 30 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -12.93 | 169.52 | 663 | 4.4 | 30 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -12.66 | 169.46 | 658 | 4.6 | 43 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -12.66 | 169.46 | 658 | 4.6 | 43 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -14.82 | 171.17 | 658 | 4.7 | 49 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -14.82 | 171.17 | 658 | 4.7 | 49 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -14.82 | 171.17 | 658 | 4.7 | 49 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -18.89 | 181.24 | 655 | 4.1 | 14 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.96 | 181.4 | 655 | 4.3 | 20 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.96 | 181.4 | 655 | 4.3 | 20 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -13.09 | 169.28 | 654 | 4.4 | 22 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -13.09 | 169.28 | 654 | 4.4 | 22 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.17 | 181.98 | 651 | 4.8 | 43 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -18.17 | 181.98 | 651 | 4.8 | 43 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -20.62 | 181.03 | 650 | 4.2 | 15 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.42 | 181.96 | 649 | 4 | 11 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -18.12 | 181.88 | 649 | 5.4 | 88 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -23.7 | 179.6 | 646 | 4.2 | 21 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -13.05 | 169.58 | 644 | 4.9 | 68 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -13.05 | 169.58 | 644 | 4.9 | 68 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -26 | 178.43 | 644 | 4.9 | 27 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -26 | 178.43 | 644 | 4.9 | 27 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -14.28 | 170.34 | 642 | 4.7 | 29 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -14.28 | 170.34 | 642 | 4.7 | 29 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -14.28 | 170.34 | 642 | 4.7 | 29 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -17.95 | 181.37 | 642 | 4 | 17 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -18.48 | 181.49 | 641 | 5 | 49 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -12.93 | 169.63 | 641 | 5.1 | 57 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -13.45 | 170.3 | 641 | 5.3 | 93 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -17.82 | 181.83 | 640 | 4.3 | 24 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.82 | 181.83 | 640 | 4.3 | 24 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.04 | 181.75 | 640 | 4.5 | 47 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -18.04 | 181.75 | 640 | 4.5 | 47 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.04 | 181.75 | 640 | 4.5 | 47 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -18.18 | 180.63 | 639 | 4.6 | 39 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.18 | 180.63 | 639 | 4.6 | 39 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -13.84 | 170.62 | 638 | 4.6 | 20 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -13.84 | 170.62 | 638 | 4.6 | 20 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -21.03 | 180.78 | 638 | 4 | 14 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.36 | 181.19 | 637 | 4.2 | 23 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -14.99 | 171.39 | 637 | 4.3 | 21 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -14.99 | 171.39 | 637 | 4.3 | 21 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21.33 | 180.69 | 636 | 4.6 | 29 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21.33 | 180.69 | 636 | 4.6 | 29 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -18 | 180.62 | 636 | 5 | 100 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -18.05 | 180.86 | 632 | 4.4 | 15 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -18.05 | 180.86 | 632 | 4.4 | 15 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.21 | 180.87 | 631 | 5.2 | 69 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -18.26 | 180.98 | 631 | 4.8 | 36 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -18.26 | 180.98 | 631 | 4.8 | 36 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -19.77 | 181.4 | 630 | 5.1 | 54 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -12.95 | 169.09 | 629 | 4.5 | 19 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -12.95 | 169.09 | 629 | 4.5 | 19 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -12.95 | 169.09 | 629 | 4.5 | 19 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -18.08 | 180.7 | 628 | 5.2 | 72 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -21.96 | 179.62 | 627 | 5 | 45 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -20.2 | 180.9 | 627 | 4.1 | 11 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.94 | 180.6 | 627 | 4.5 | 29 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.94 | 180.6 | 627 | 4.5 | 29 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -17.94 | 180.6 | 627 | 4.5 | 29 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -21.08 | 180.85 | 627 | 5.9 | 119 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -17.97 | 181.66 | 626 | 4.1 | 19 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.98 | 180.5 | 626 | 4.1 | 19 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.99 | 181.02 | 626 | 4.5 | 36 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.99 | 181.02 | 626 | 4.5 | 36 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -20.99 | 181.02 | 626 | 4.5 | 36 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -21.14 | 181.06 | 625 | 4.5 | 35 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -21.14 | 181.06 | 625 | 4.5 | 35 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21.14 | 181.06 | 625 | 4.5 | 35 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -21.3 | 180.82 | 624 | 4.3 | 14 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -21.3 | 180.82 | 624 | 4.3 | 14 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.14 | 180.87 | 624 | 5.5 | 105 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -18.44 | 181.04 | 624 | 4.2 | 21 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.47 | 179.59 | 622 | 4.3 | 19 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.47 | 179.59 | 622 | 4.3 | 19 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -17.88 | 180.58 | 622 | 4.2 | 23 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.83 | 181.01 | 622 | 4.3 | 15 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.83 | 181.01 | 622 | 4.3 | 15 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -17.95 | 181.65 | 619 | 4.3 | 26 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.95 | 181.65 | 619 | 4.3 | 26 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21.18 | 180.92 | 619 | 4.5 | 18 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -21.18 | 180.92 | 619 | 4.5 | 18 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21.18 | 180.92 | 619 | 4.5 | 18 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -18.13 | 181.52 | 618 | 4.6 | 41 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.13 | 181.52 | 618 | 4.6 | 41 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -13.36 | 172.76 | 618 | 4.4 | 18 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -13.36 | 172.76 | 618 | 4.4 | 18 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21.77 | 181 | 618 | 4.1 | 10 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -26.11 | 178.3 | 617 | 4.8 | 39 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -26.11 | 178.3 | 617 | 4.8 | 39 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -21.68 | 180.63 | 617 | 5 | 63 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -21.39 | 180.68 | 617 | 4.5 | 18 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -21.39 | 180.68 | 617 | 4.5 | 18 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21.39 | 180.68 | 617 | 4.5 | 18 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -21.3 | 180.92 | 617 | 4.5 | 26 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| … | … | … | … | … | … |
(plot/render-image
{:data quakes-magnitude
:mapping {:x :long :y :lat :color :depth :facet :magnitude}
:scales grey-depth
:charts [(chart/scatter {:size 7 :stroke-color :black :stroke-width 0.5})]
:facets {:columns 2}
:aspect :iso
:legend false
:labels {:x "Longitude" :y "Latitude"}}
{:width 700 :height 800})
38.5.6 Fig 5.6 With a colour key
Source: Lattice Fig 5.6. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data quakes-magnitude
:mapping {:x :long :y :lat :color :depth :facet :magnitude}
:scales grey-depth
:charts [(chart/scatter {:size 7 :stroke-color :black :stroke-width 0.5})]
:facets {:columns 2}
:aspect :iso
:labels {:x "Longitude" :y "Latitude"}}
{:width 750 :height 800})
38.5.7 Fig 5.7 Plot types
Lattice’s type argument drawn with cljplot2 charts on one seeded data set: points, lines in data order, both, a regression line, the grid alone, steps (two kinds), stems, averages per x, a loess curve. The bottom row repeats the last five with x and y exchanged (lattice’s horizontal = TRUE): the same charts of the swapped columns in a :flip plot.
Source: Lattice Fig 5.7.
(let [rng (r/rng :mersenne 2007041)
grid-xs (mapv #(+ -10.0 (* 20.0 (/ % 14.0))) (range 15))
xy (vec (for [_ (range 30)
:let [x (grid-xs (r/irandom rng 15))]]
{:x x :y (+ x (* 0.25 (m/sq (+ x 1.0))) (r/grandom rng 0.0 5.0))}))
sorted (sort-by :x xy)
steps (fn [corner] (concat (mapcat (fn [a b] [a (corner a b)]) sorted (rest sorted)) [(last sorted)]))
averages (for [[x rs] (sort-by key (group-by :x xy))] {:x x :y (stats/mean (map :y rs))})
types [["p" xy [(chart/scatter)]]
["l" xy [(chart/line {:sort false})]]
["o" xy [(chart/line {:sort false}) (chart/scatter)]]
["r" xy [(chart/smooth {:method :lm :band :none})]]
["g" xy [(chart/scatter {:color [0 0 0 0]})]]
["s" (steps (fn [a b] {:x (:x b) :y (:y a)})) [(chart/line {:sort false})]]
["S" (steps (fn [a b] {:x (:x a) :y (:y b)})) [(chart/line {:sort false})]]
["h" xy [(chart/segment {:yend 0})]]
["a" averages [(chart/line)]]
["smooth" xy [(chart/smooth {:band :none})]]]
panel (fn [[title data charts]]
{:data data :mapping {:x :x :y :y} :charts charts
:labels {:title (str "\"" title "\"") :x nil :y nil}})
swapped (mapv (fn [{:keys [x y]}] {:x y :y x}) xy)]
(plot/render-image
(plot/arrange (concat (map panel types)
;; horizontal: the same charts of the swapped columns, drawn flipped
(for [[title _ charts] (drop 5 types)
:let [sorted (sort-by :x swapped)
data (case title
"s" (concat (mapcat (fn [a b] [a {:x (:x b) :y (:y a)}]) sorted (rest sorted)) [(last sorted)])
"S" (concat (mapcat (fn [a b] [a {:x (:x a) :y (:y b)}]) sorted (rest sorted)) [(last sorted)])
"a" (for [[x rs] (sort-by key (group-by :x swapped))] {:x x :y (stats/mean (map :y rs))})
swapped)]]
(assoc (panel [(str title ", horizontal") data charts]) :flip true)))
{:columns 5})
{:width 1000 :height 650}))
38.5.8 Fig 5.8 Scatter plot with a loess curve
Peak ground acceleration against distance from the epicentre, for 23 Californian earthquakes.
Source: Lattice Fig 5.8. Data: Western US earthquakes: ground acceleration, R MEMSS package Earthquake (Joyner & Boore 1981); licence: GPL (>= 2) (MEMSS).
(def earthquake-labels {:x "Distance From Epicenter (km)" :y "Maximum Horizontal Acceleration (g)"})(plot/render-image
{:data earthquake
:mapping {:x :distance :y :accel}
:charts [(chart/scatter) (chart/smooth {:band :none})]
:labels earthquake-labels}
{:width 650 :height 500})
38.5.9 Fig 5.9 Logarithmic axes
Source: Lattice Fig 5.9. Data: Western US earthquakes: ground acceleration, R MEMSS package Earthquake (Joyner & Boore 1981); licence: GPL (>= 2) (MEMSS).
(def log2-axes
"Base-2 logarithmic x and y scales labelled as powers of two."
{:x {:kind :log :base 2 :formatter :power} :y {:kind :log :base 2 :formatter :power}})(plot/render-image
{:data earthquake
:mapping {:x :distance :y :accel}
:scales log2-axes
:charts [(chart/scatter) (chart/smooth {:band :none})]
:labels earthquake-labels}
{:width 650 :height 500})
38.5.10 Fig 5.10 Local fits by magnitude
A panel per magnitude interval (three equal-count intervals overlapping by 10 %): a loess curve per panel (the book uses locfit) and the least-squares line of all quakes on the log-log scale, the same in every panel.
Source: Lattice Fig 5.10. Data: Western US earthquakes: ground acceleration, R MEMSS package Earthquake (Joyner & Boore 1981); licence: GPL (>= 2) (MEMSS).
(let [model (regression/lm (mapv #(m/log2 (:accel %)) earthquake) (mapv (fn [row] [(m/log2 (:distance row))]) earthquake))
intercept (:intercept model)
slope (first (:beta model))]
(plot/render-image
{:data (shingle/shingle earthquake :richter {:count 3 :overlap 0.1 :as :magnitude :label "Magnitude"})
:mapping {:x :distance :y :accel :facet :magnitude}
:scales log2-axes
:charts [(chart/scatter)
(chart/smooth {:band :none :color :grey :width 2})
(chart/function {:f (fn [d] (m/pow 2.0 (+ intercept (* slope (m/log2 d))))) :color :black})]
:facets {:columns 3}
:labels earthquake-labels}
{:width 900 :height 400}))
38.5.11 Fig 5.11 Several variables against one
Seattle-Tacoma weather, January to March 2007: minimum and maximum temperature and rainfall by day.
Source: Lattice Fig 5.11. Data: Seattle-Tacoma airport weather, Jan-Mar 2007, R latticeExtra package SeatacWeather (NOAA); licence: GPL (>= 2) (latticeExtra).
(def months {:facet {:domain ["January" "February" "March"]}})(def seatac-long
"SeaTac weather, one row per day and variable."
(for [row seatac, k [:min-temp :max-temp :precip]]
{:month (:month row) :day (:day row) :variable (name k) :value (k row)}))| month | day | variable | value |
|---|---|---|---|
| January | 1 | min-temp | 34 |
| January | 1 | max-temp | 43 |
| January | 1 | precip | 0.13 |
| January | 2 | min-temp | 45 |
| January | 2 | max-temp | 56 |
| January | 2 | precip | 1.77 |
| January | 3 | min-temp | 43 |
| January | 3 | max-temp | 48 |
| January | 3 | precip | 1.01 |
| January | 4 | min-temp | 37 |
| January | 4 | max-temp | 42 |
| January | 4 | precip | 0.06 |
| January | 5 | min-temp | 31 |
| January | 5 | max-temp | 43 |
| January | 5 | precip | 0.19 |
| January | 6 | min-temp | 36 |
| January | 6 | max-temp | 44 |
| January | 6 | precip | |
| January | 7 | min-temp | 40 |
| January | 7 | max-temp | 49 |
| January | 7 | precip | 0.93 |
| January | 8 | min-temp | 38 |
| January | 8 | max-temp | 47 |
| January | 8 | precip | 0 |
| January | 9 | min-temp | 41 |
| January | 9 | max-temp | 51 |
| January | 9 | precip | 0.16 |
| January | 10 | min-temp | 32 |
| January | 10 | max-temp | 36 |
| January | 10 | precip | 0.01 |
| January | 11 | min-temp | 27 |
| January | 11 | max-temp | 31 |
| January | 11 | precip | 0 |
| January | 12 | min-temp | 19 |
| January | 12 | max-temp | 31 |
| January | 12 | precip | |
| January | 13 | min-temp | 21 |
| January | 13 | max-temp | 29 |
| January | 13 | precip | 0 |
| January | 14 | min-temp | 20 |
| January | 14 | max-temp | 35 |
| January | 14 | precip | |
| January | 15 | min-temp | 23 |
| January | 15 | max-temp | 35 |
| January | 15 | precip | |
| January | 16 | min-temp | 28 |
| January | 16 | max-temp | 35 |
| January | 16 | precip | 0.18 |
| January | 17 | min-temp | 33 |
| January | 17 | max-temp | 39 |
| January | 17 | precip | |
| January | 18 | min-temp | 34 |
| January | 18 | max-temp | 42 |
| January | 18 | precip | 0.16 |
| January | 19 | min-temp | 38 |
| January | 19 | max-temp | 42 |
| January | 19 | precip | 0.08 |
| January | 20 | min-temp | 37 |
| January | 20 | max-temp | 45 |
| January | 20 | precip | |
| January | 21 | min-temp | 37 |
| January | 21 | max-temp | 42 |
| January | 21 | precip | |
| January | 22 | min-temp | 40 |
| January | 22 | max-temp | 50 |
| January | 22 | precip | 0 |
| January | 23 | min-temp | 44 |
| January | 23 | max-temp | 52 |
| January | 23 | precip | 0 |
| January | 24 | min-temp | 35 |
| January | 24 | max-temp | 51 |
| January | 24 | precip | |
| January | 25 | min-temp | 33 |
| January | 25 | max-temp | 43 |
| January | 25 | precip | 0.02 |
| January | 26 | min-temp | 37 |
| January | 26 | max-temp | 44 |
| January | 26 | precip | |
| January | 27 | min-temp | 32 |
| January | 27 | max-temp | 52 |
| January | 27 | precip | |
| January | 28 | min-temp | 28 |
| January | 28 | max-temp | 50 |
| January | 28 | precip | |
| January | 29 | min-temp | 28 |
| January | 29 | max-temp | 40 |
| January | 29 | precip | |
| January | 30 | min-temp | 33 |
| January | 30 | max-temp | 48 |
| January | 30 | precip | |
| January | 31 | min-temp | 28 |
| January | 31 | max-temp | 48 |
| January | 31 | precip | |
| February | 1 | min-temp | 30 |
| February | 1 | max-temp | 49 |
| February | 1 | precip | |
| February | 2 | min-temp | 28 |
| February | 2 | max-temp | 44 |
| February | 2 | precip | |
| February | 3 | min-temp | 31 |
| … | … | … | … |
(plot/render-image
{:data seatac-long
:mapping {:x :day :y :value :group :variable :facet :month}
:scales months
:charts [(chart/line {:color :black})]
:facets {:columns 3}
:labels {:x "day" :y "Temperature and Rainfall"}}
{:width 900 :height 400})
38.5.12 Fig 5.12 Lines and stems
Rainfall scaled to the temperature range (× 80 / its maximum) and drawn as stems.
Source: Lattice Fig 5.12. Data: Seattle-Tacoma airport weather, Jan-Mar 2007, R latticeExtra package SeatacWeather (NOAA); licence: GPL (>= 2) (latticeExtra).
(def max-precip (reduce max (keep :precip seatac)))(plot/render-image
{:data seatac
:mapping {:x :day :facet :month}
:scales months
:charts [(chart/line {:mapping {:y :min-temp} :color :black})
(chart/line {:mapping {:y :max-temp} :color :black})
(chart/segment {:data (map #(update % :precip (fn [p] (some-> p (* 80.0) (/ max-precip)))) seatac)
:mapping {:y :precip} :yend 0 :color :black})]
:facets {:columns 3}
:labels {:x "day" :y "Temperature and Rainfall"}}
{:width 900 :height 400})
38.5.13 Fig 5.13 Temperature and rainfall, each on its own axis
The book adds a rainfall axis on the right of one panel; cljplot2 has no secondary axes, so the two measures are two plots - each with its own axis.
Source: Lattice Fig 5.13. Data: Seattle-Tacoma airport weather, Jan-Mar 2007, R latticeExtra package SeatacWeather (NOAA); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
(plot/arrange [{:data (filter #(not= "precip" (:variable %)) seatac-long)
:mapping {:x :day :y :value :group :variable :facet :month}
:scales months
:charts [(chart/line {:color :black})]
:facets {:columns 3}
:labels {:x nil :y "Temperature (Fahrenheit)"}}
{:data seatac
:mapping {:x :day :y :precip :facet :month}
:scales months
:charts [(chart/segment {:yend 0 :color :black})]
:facets {:columns 3}
:labels {:x "day" :y "Rainfall (inches)"}}]
{:columns 1})
{:width 900 :height 600})
38.5.14 Fig 5.14 Hexagonal binning
Two fluorescence channels of the GvHD cells (asinh-transformed), counted in hexagons, a panel per day; grey levels by the square root of the count (:transform :sqrt, lattice’s trans = sqrt).
Source: Lattice Fig 5.14. Data: Flow cytometry of a GvHD patient, 10 days, R latticeExtra package gvhd10 (Brinkman et al. 2007); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
{:data (mapv (fn [row] {:days (:days row) :ssc (m/asinh (:ssc-h row)) :fl2 (m/asinh (:fl2-h row))}) gvhd10)
:mapping {:x :fl2 :y :ssc :facet :days}
:scales {:x {:domain [0 10.5]} :color {:range [[200 200 200] [0 0 0]] :transform :sqrt}}
:charts [(chart/bin2d {:bins 30})]
:facets {:columns 4}
:aspect :iso
:labels {:x "asinh(FL2.H)" :y "asinh(SSC.H)"}}
{:width 900 :height 550})
38.5.15 Fig 5.15 Scatter-plot matrix
Source: Lattice Fig 5.15. Data: Violent crime rates by US state (1973), R datasets package USArrests (McNeil 1977); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
(plot/pairs us-arrests {:variables [:murder :assault :urban-pop :rape]
:upper (chart/scatter) :diagonal :names})
{:width 700 :height 700})
38.5.16 Fig 5.16 A matrix per region
Arrest rates of the states of each census region (joined from the state facts): points and a loess curve with lattice’s panel.loess settings (span 2/3, degree 1) - with a dozen states per region, ggplot2’s degree 2 bends.
Source: Lattice Fig 5.16. Data: Violent crime rates by US state (1973), R datasets package USArrests (McNeil 1977); licence: Part of R (GPL-2 | GPL-3).
(let [region (into {} (map (juxt :name :region) states))
rows (map #(assoc % :region (region (:state %))) us-arrests)
cell [(chart/scatter {:size 3}) (chart/smooth {:band :none :method-params {:bandwidth (/ 2.0 3.0) :degree 1}})]]
(plot/render-image
(plot/arrange (for [r ["Northeast" "South" "North Central" "West"]]
(plot/pairs (filterv #(= r (:region %)) rows)
{:variables [:urban-pop :murder :assault :rape]
:lower cell :upper cell :diagonal :names :title r}))
{:columns 2})
{:width 900 :height 800}))
38.5.17 Fig 5.17 Groups in a scatter-plot matrix
Source: Lattice Fig 5.17. Data: Motor Trend car road tests (1974), R datasets package mtcars (Henderson & Velleman 1981); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
(plot/pairs mtcars {:variables [:mpg :disp :hp :drat :wt :qsec]
:mapping {:color (levels/categorical :cyl)}
:upper (chart/scatter) :diagonal :names
:labels {:mpg "Miles/gallon" :disp "Displacement" :hp "Horsepower"
:drat "Axle ratio" :wt "Weight" :qsec "1/4 mile time"}})
{:width 900 :height 800})
38.5.18 Fig 5.18 Parallel coordinates
Six car variables, a panel per cylinder count, coloured by the number of carburettors.
Source: Lattice Fig 5.18. Data: Motor Trend car road tests (1974), R datasets package mtcars (Henderson & Velleman 1981); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data mtcars
:mapping {:color (levels/categorical :carb) :facet :cyl}
:charts [(chart/parallel {:variables [:mpg :disp :hp :drat :wt :qsec]})]
:facets {:columns 3}
:flip true
:labels {:x nil :y nil}}
{:width 900 :height 500})
38.5.19 Fig 5.19 Many translucent lines
The cells of day 13 (asinh-transformed channels), each a nearly transparent line (colour alpha 3 of 255).
Source: Lattice Fig 5.19. Data: Flow cytometry of a GvHD patient, 10 days, R latticeExtra package gvhd10 (Brinkman et al. 2007); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
{:data (for [row gvhd10 :when (= 13 (:days row))]
(update-vals (select-keys row [:fl1-h :ssc-h :fl2-h :fsc-h :fl3-h]) m/asinh))
:charts [(chart/parallel {:variables [:fl1-h :ssc-h :fl2-h :fsc-h :fl3-h] :color [140 40 40 3]})]
:flip true
:labels {:x nil :y nil}}
{:width 700 :height 600})
38.6 Chapter 6 - Trivariate Displays
38.6.1 Fig 6.1 Three-dimensional scatter plot
Earthquake locations and depths (depth growing downward) in a box, a panel per magnitude interval.
Source: Lattice Fig 6.1. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(def quakes-magnitude-4
"quakes with a shingle of four equal-count, half-overlapping magnitude intervals."
(shingle/shingle quakes :mag {:count 4 :overlap 0.5 :as :magnitude :label "Magnitude"}))| lat | long | depth | mag | stations | magnitude |
|---|---|---|---|---|---|
| -20.42 | 181.62 | 562 | 4.8 | 41 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -20.42 | 181.62 | 562 | 4.8 | 41 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -20.62 | 181.03 | 650 | 4.2 | 15 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -26 | 184.1 | 42 | 5.4 | 43 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -17.97 | 181.66 | 626 | 4.1 | 19 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.42 | 181.96 | 649 | 4 | 11 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -19.68 | 184.31 | 195 | 4 | 12 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -11.7 | 166.1 | 82 | 4.8 | 43 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -11.7 | 166.1 | 82 | 4.8 | 43 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -28.11 | 181.93 | 194 | 4.4 | 15 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -28.11 | 181.93 | 194 | 4.4 | 15 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -28.74 | 181.74 | 211 | 4.7 | 35 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -28.74 | 181.74 | 211 | 4.7 | 35 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -28.74 | 181.74 | 211 | 4.7 | 35 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -17.47 | 179.59 | 622 | 4.3 | 19 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.47 | 179.59 | 622 | 4.3 | 19 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21.44 | 180.69 | 583 | 4.4 | 13 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -21.44 | 180.69 | 583 | 4.4 | 13 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -12.26 | 167 | 249 | 4.6 | 16 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -12.26 | 167 | 249 | 4.6 | 16 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -18.54 | 182.11 | 554 | 4.4 | 19 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -18.54 | 182.11 | 554 | 4.4 | 19 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -21 | 181.66 | 600 | 4.4 | 10 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -21 | 181.66 | 600 | 4.4 | 10 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -20.7 | 169.92 | 139 | 6.1 | 94 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -15.94 | 184.95 | 306 | 4.3 | 11 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -15.94 | 184.95 | 306 | 4.3 | 11 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -13.64 | 165.96 | 50 | 6 | 83 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -17.83 | 181.5 | 590 | 4.5 | 21 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -17.83 | 181.5 | 590 | 4.5 | 21 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -17.83 | 181.5 | 590 | 4.5 | 21 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -23.5 | 179.78 | 570 | 4.4 | 13 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -23.5 | 179.78 | 570 | 4.4 | 13 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -22.63 | 180.31 | 598 | 4.4 | 18 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -22.63 | 180.31 | 598 | 4.4 | 18 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -20.84 | 181.16 | 576 | 4.5 | 17 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.84 | 181.16 | 576 | 4.5 | 17 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -20.84 | 181.16 | 576 | 4.5 | 17 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -10.98 | 166.32 | 211 | 4.2 | 12 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -23.3 | 180.16 | 512 | 4.4 | 18 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -23.3 | 180.16 | 512 | 4.4 | 18 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -30.2 | 182 | 125 | 4.7 | 22 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -30.2 | 182 | 125 | 4.7 | 22 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -30.2 | 182 | 125 | 4.7 | 22 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -19.66 | 180.28 | 431 | 5.4 | 57 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -17.94 | 181.49 | 537 | 4 | 15 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -14.72 | 167.51 | 155 | 4.6 | 18 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -14.72 | 167.51 | 155 | 4.6 | 18 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -16.46 | 180.79 | 498 | 5.2 | 79 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -20.97 | 181.47 | 582 | 4.5 | 25 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -20.97 | 181.47 | 582 | 4.5 | 25 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -20.97 | 181.47 | 582 | 4.5 | 25 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -19.84 | 182.37 | 328 | 4.4 | 17 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -19.84 | 182.37 | 328 | 4.4 | 17 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -22.58 | 179.24 | 553 | 4.6 | 21 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -22.58 | 179.24 | 553 | 4.6 | 21 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -16.32 | 166.74 | 50 | 4.7 | 30 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -16.32 | 166.74 | 50 | 4.7 | 30 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -16.32 | 166.74 | 50 | 4.7 | 30 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -15.55 | 185.05 | 292 | 4.8 | 42 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -15.55 | 185.05 | 292 | 4.8 | 42 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -23.55 | 180.8 | 349 | 4 | 10 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -16.3 | 186 | 48 | 4.5 | 10 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -16.3 | 186 | 48 | 4.5 | 10 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -16.3 | 186 | 48 | 4.5 | 10 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -25.82 | 179.33 | 600 | 4.3 | 13 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -25.82 | 179.33 | 600 | 4.3 | 13 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.73 | 169.23 | 206 | 4.5 | 17 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -18.73 | 169.23 | 206 | 4.5 | 17 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.73 | 169.23 | 206 | 4.5 | 17 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -17.64 | 181.28 | 574 | 4.6 | 17 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -17.64 | 181.28 | 574 | 4.6 | 17 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -17.66 | 181.4 | 585 | 4.1 | 17 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -18.82 | 169.33 | 230 | 4.4 | 11 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -18.82 | 169.33 | 230 | 4.4 | 11 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -37.37 | 176.78 | 263 | 4.7 | 34 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -37.37 | 176.78 | 263 | 4.7 | 34 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -37.37 | 176.78 | 263 | 4.7 | 34 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -15.31 | 186.1 | 96 | 4.6 | 32 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -15.31 | 186.1 | 96 | 4.6 | 32 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -24.97 | 179.82 | 511 | 4.4 | 23 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -24.97 | 179.82 | 511 | 4.4 | 23 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -15.49 | 186.04 | 94 | 4.3 | 26 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -15.49 | 186.04 | 94 | 4.3 | 26 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -19.23 | 169.41 | 246 | 4.6 | 27 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -19.23 | 169.41 | 246 | 4.6 | 27 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -30.1 | 182.3 | 56 | 4.9 | 34 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -30.1 | 182.3 | 56 | 4.9 | 34 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -26.4 | 181.7 | 329 | 4.5 | 24 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -26.4 | 181.7 | 329 | 4.5 | 24 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -26.4 | 181.7 | 329 | 4.5 | 24 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| -11.77 | 166.32 | 70 | 4.4 | 18 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -11.77 | 166.32 | 70 | 4.4 | 18 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -24.12 | 180.08 | 493 | 4.3 | 21 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -24.12 | 180.08 | 493 | 4.3 | 21 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -18.97 | 185.25 | 129 | 5.1 | 73 | #cljplot2.data.shingle.Interval{:lo 4.65, :hi 6.45, :label "Magnitude", :closed nil, :digits nil} |
| -18.75 | 182.35 | 554 | 4.2 | 13 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -19.26 | 184.42 | 223 | 4 | 15 | #cljplot2.data.shingle.Interval{:lo 3.95, :hi 4.55, :label "Magnitude", :closed nil, :digits nil} |
| -22.75 | 173.2 | 46 | 4.6 | 26 | #cljplot2.data.shingle.Interval{:lo 4.25, :hi 4.75, :label "Magnitude", :closed nil, :digits nil} |
| -22.75 | 173.2 | 46 | 4.6 | 26 | #cljplot2.data.shingle.Interval{:lo 4.45, :hi 4.95, :label "Magnitude", :closed nil, :digits nil} |
| … | … | … | … | … | … |
(plot/render-image
{:data quakes-magnitude-4
:mapping {:x :lat :y :long :z :depth :facet :magnitude}
:charts [(chart/cloud {:domain {:z [680 40]} :view {:azimuth -105 :elevation 20 :distance 0.2} :size 3
:axis-titles {:x "Latitude" :y "Longitude" :z "Depth"}})]
:facets {:columns 2}}
{:width 800 :height 700})
38.6.2 Fig 6.2 Another view
Source: Lattice Fig 6.2. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data quakes-magnitude-4
:mapping {:x :lat :y :long :z :depth :facet :magnitude}
:charts [(chart/cloud {:domain {:z [680 40]} :view {:azimuth -80 :elevation 20 :distance 0.2} :size 3
:axis-titles {:x "Latitude" :y "Longitude" :z "Depth (km)"}})]
:facets {:columns 2}}
{:width 800 :height 700})
38.6.3 Fig 6.3 Turning the cloud
One cloud from eight directions: turned by lattice’s z = 30, 10, -10, -30 degrees down the rows (azimuth -z; lattice’s rows run bottom-up), the first column slightly higher (in place of the book’s 3-degree y turn).
Source: Lattice Fig 6.3. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
(plot/arrange (for [turn [30 10 -10 -30], tilt [33 30]]
{:data quakes
:mapping {:x :long :y :lat :z :depth}
:charts [(chart/cloud {:domain {:z [690 30]} :view {:azimuth (- turn) :elevation tilt :distance 0.2}
:axes false :size 2})]})
{:columns 2})
{:width 600 :height 800})
38.6.4 Fig 6.4 Spikes
Population density of the 48 contiguous states (people per square mile) as spikes over their centres.
Source: Lattice Fig 6.4. Data: US state facts (1970s), R datasets packages state.x77, state.name, state.abb, state.region, state.division, state.center (US Census); licence: Part of R (GPL-2 | GPL-3).
(def state-density
(for [{:keys [name long lat population area]} states
:when (not (#{"Alaska" "Hawaii"} name))]
{:name name :long long :lat lat :density (/ (* 1000.0 population) area)}))| name | long | lat | density |
|---|---|---|---|
| Alabama | -86.7509 | 32.5901 | 71.29052614971997 |
| Arizona | -111.625 | 34.2192 | 19.503249072008604 |
| Arkansas | -92.2992 | 34.7336 | 40.61988641832708 |
| California | -119.773 | 36.5341 | 135.57089043943182 |
| Colorado | -105.513 | 38.6777 | 24.487789834820653 |
| Connecticut | -72.3573 | 41.5928 | 637.5976964212258 |
| Delaware | -74.9841 | 38.6777 | 292.12916246215946 |
| Florida | -81.685 | 27.8744 | 153.02273987798114 |
| Georgia | -83.3736 | 32.3329 | 84.91037142906342 |
| Idaho | -113.93 | 43.5648 | 9.833448238325047 |
| Illinois | -89.3776 | 40.0495 | 200.85025471765803 |
| Indiana | -86.0808 | 40.0495 | 147.18674682106547 |
| Iowa | -93.3714 | 41.9358 | 51.14316869559 |
| Kansas | -98.1156 | 38.4204 | 27.877291012019025 |
| Kentucky | -84.7674 | 37.3915 | 85.42244640605297 |
| Louisiana | -92.2724 | 30.6181 | 84.70954818606721 |
| Maine | -68.9801 | 45.6226 | 34.21733505821475 |
| Maryland | -76.6459 | 39.2778 | 416.7424931756142 |
| Massachusetts | -71.58 | 42.3645 | 742.9082545361615 |
| Michigan | -84.687 | 43.1361 | 160.35693542425682 |
| Minnesota | -94.6043 | 46.3943 | 49.45200469169746 |
| Mississippi | -89.8065 | 32.6758 | 49.496786197564276 |
| Missouri | -92.5137 | 38.3347 | 69.0919631857381 |
| Montana | -109.32 | 46.823 | 5.124083881115759 |
| Nebraska | -99.5898 | 41.3356 | 20.187492645424474 |
| Nevada | -116.851 | 39.1063 | 5.369054227447697 |
| New Hampshire | -71.3924 | 43.3934 | 89.9523651268417 |
| New Jersey | -74.2336 | 39.9637 | 975.0033240260603 |
| New Mexico | -105.942 | 34.4764 | 9.42246235956907 |
| New York | -75.1449 | 43.1361 | 377.9139052079195 |
| North Carolina | -78.4686 | 35.4195 | 111.50047133079225 |
| North Dakota | -100.099 | 47.2517 | 9.195501854979574 |
| Ohio | -82.5963 | 40.221 | 261.98901769371565 |
| Oklahoma | -97.1239 | 35.5053 | 39.47253641941206 |
| Oregon | -120.068 | 43.9078 | 23.74615320635449 |
| Pennsylvania | -77.45 | 40.9069 | 263.7548369879465 |
| Rhode Island | -71.1244 | 41.5928 | 887.5119161105815 |
| South Carolina | -80.5056 | 33.619 | 93.16790736145575 |
| South Dakota | -99.7238 | 44.3365 | 8.965835033901651 |
| Tennessee | -86.456 | 35.6767 | 100.97270615563299 |
| Texas | -98.7857 | 31.3897 | 46.68223122525121 |
| Utah | -111.33 | 39.1063 | 14.653576300916 |
| Vermont | -72.545 | 44.2508 | 50.93341966116327 |
| Virginia | -78.2005 | 37.563 | 125.21367521367522 |
| Washington | -119.746 | 47.4231 | 53.46252065494968 |
| West Virginia | -80.6665 | 38.4204 | 74.74034067303698 |
| Wisconsin | -89.9941 | 44.5937 | 84.25749118683902 |
| Wyoming | -107.256 | 43.0504 | 3.868193368517433 |
(plot/render-image
{:data state-density
:mapping {:x :long :y :lat :z :density}
:charts [(chart/cloud {:type :spikes :stroke-width 2 :view {:azimuth -40 :elevation 30 :distance 0.2}
:domain {:z [0 (reduce max (map :density state-density))]}
:axis-titles {:x "long" :y "lat" :z "density"}})]}
{:width 600 :height 500})
Not reproduced: Fig 6.5 (the spikes over a map of the states - no maps in cljplot2).
38.6.5 Fig 6.6 Ozone by wind and temperature
Cube root of ozone against wind speed and temperature, a panel per radiation interval.
Source: Lattice Fig 6.6. Data: Ozone and weather, New York 1973, R lattice package environmental (Bruntz et al. 1974; Cleveland 1993); licence: GPL (>= 2) (lattice).
(def env
"environmental with the cube root of ozone."
(mapv #(update % :ozone m/cbrt) (nu/dataset :environmental)))| ozone | radiation | temperature | wind |
|---|---|---|---|
| 3.4482172403827303 | 190 | 67 | 7.4 |
| 3.3019272488946267 | 118 | 72 | 8 |
| 2.2894284851066637 | 149 | 74 | 12.6 |
| 2.6207413942088964 | 313 | 62 | 11.5 |
| 2.8438669798515654 | 299 | 65 | 8.6 |
| 2.668401648721945 | 99 | 59 | 13.8 |
| 2.0 | 19 | 61 | 20.1 |
| 2.5198420997897464 | 256 | 69 | 9.7 |
| 2.2239800905693157 | 290 | 66 | 9.2 |
| 2.41014226417523 | 274 | 68 | 10.9 |
| 2.6207413942088964 | 65 | 58 | 13.2 |
| 2.41014226417523 | 334 | 64 | 11.5 |
| 3.2396118012774835 | 307 | 66 | 12 |
| 1.8171205928321397 | 78 | 57 | 18.4 |
| 3.107232505953859 | 322 | 68 | 11.5 |
| 2.2239800905693157 | 44 | 62 | 9.7 |
| 1.0 | 8 | 59 | 9.7 |
| 2.2239800905693157 | 320 | 73 | 16.6 |
| 1.5874010519681996 | 25 | 61 | 9.7 |
| 3.174802103936399 | 92 | 61 | 12 |
| 2.8438669798515654 | 13 | 67 | 12 |
| 3.556893304490063 | 252 | 81 | 14.9 |
| 4.86294413109428 | 223 | 79 | 5.7 |
| 3.3322218516459534 | 279 | 76 | 7.4 |
| 3.072316825685847 | 127 | 82 | 9.7 |
| 4.140817749422853 | 291 | 90 | 13.8 |
| 3.391211443014167 | 323 | 87 | 11.5 |
| 2.8438669798515654 | 148 | 82 | 8 |
| 2.7589241763811208 | 191 | 77 | 14.9 |
| 3.3322218516459534 | 284 | 72 | 20.7 |
| 2.7144176165949068 | 37 | 65 | 9.2 |
| 2.2894284851066637 | 120 | 73 | 11.5 |
| 2.3513346877207577 | 137 | 76 | 10.3 |
| 5.129927840030091 | 269 | 84 | 4 |
| 3.6593057100229713 | 248 | 85 | 9.2 |
| 3.174802103936399 | 236 | 81 | 9.2 |
| 4.0 | 175 | 83 | 4.6 |
| 3.419951893353394 | 314 | 83 | 10.9 |
| 4.254320865115006 | 276 | 88 | 5.1 |
| 4.594700892207039 | 267 | 92 | 6.3 |
| 4.594700892207039 | 272 | 92 | 5.7 |
| 4.396829672158179 | 175 | 89 | 7.4 |
| 2.154434690031884 | 264 | 73 | 14.3 |
| 3.0 | 175 | 81 | 14.9 |
| 1.9129311827723892 | 48 | 80 | 14.3 |
| 3.6342411856642793 | 260 | 81 | 6.9 |
| 3.2710663101885897 | 274 | 82 | 10.3 |
| 3.936497183102173 | 285 | 84 | 6.3 |
| 4.2908404270262075 | 187 | 87 | 5.1 |
| 3.9790572078963917 | 220 | 85 | 11.5 |
| 2.5198420997897464 | 7 | 74 | 6.9 |
| 4.308869380063768 | 294 | 86 | 8.6 |
| 4.762203155904598 | 223 | 85 | 8 |
| 2.7144176165949068 | 81 | 82 | 8.6 |
| 3.732511156817248 | 82 | 86 | 12 |
| 4.344481485768612 | 213 | 88 | 7.4 |
| 3.684031498640387 | 275 | 86 | 7.4 |
| 4.0 | 253 | 83 | 7.4 |
| 3.8929964158732604 | 254 | 81 | 9.2 |
| 3.391211443014167 | 83 | 81 | 6.9 |
| 2.080083823051904 | 24 | 81 | 13.8 |
| 2.5198420997897464 | 77 | 82 | 7.4 |
| 4.959675663842301 | 255 | 89 | 4 |
| 4.464745095584537 | 229 | 90 | 10.3 |
| 4.791419857062784 | 207 | 90 | 8 |
| 3.530348335326063 | 192 | 86 | 11.5 |
| 3.0365889718756627 | 273 | 82 | 11.5 |
| 4.020725758589058 | 157 | 80 | 9.7 |
| 2.8020393306553872 | 71 | 77 | 10.3 |
| 3.8929964158732604 | 51 | 79 | 6.3 |
| 2.8438669798515654 | 115 | 76 | 7.4 |
| 3.141380652391393 | 244 | 78 | 10.9 |
| 3.530348335326063 | 190 | 78 | 10.3 |
| 2.7589241763811208 | 259 | 77 | 15.5 |
| 2.080083823051904 | 36 | 72 | 14.3 |
| 3.556893304490063 | 212 | 79 | 9.7 |
| 5.5178483527622415 | 238 | 81 | 3.4 |
| 4.179339196381232 | 215 | 86 | 8 |
| 4.235823584254893 | 203 | 97 | 9.7 |
| 4.904868131524017 | 225 | 94 | 2.3 |
| 4.379519139887889 | 237 | 96 | 6.3 |
| 4.396829672158179 | 188 | 94 | 6.3 |
| 4.5788569702133275 | 167 | 91 | 6.9 |
| 4.272658681697917 | 197 | 92 | 5.1 |
| 4.179339196381232 | 183 | 93 | 2.8 |
| 4.497941445275415 | 189 | 93 | 4.6 |
| 3.608826080138695 | 95 | 87 | 7.4 |
| 3.174802103936399 | 92 | 84 | 15.5 |
| 2.7144176165949068 | 252 | 80 | 10.9 |
| 2.8438669798515654 | 220 | 78 | 10.3 |
| 2.7589241763811208 | 230 | 75 | 10.9 |
| 2.8844991406148166 | 259 | 73 | 9.7 |
| 3.530348335326063 | 236 | 81 | 14.9 |
| 2.7589241763811208 | 259 | 76 | 15.5 |
| 3.0365889718756627 | 238 | 77 | 6.3 |
| 2.080083823051904 | 24 | 71 | 10.9 |
| 2.3513346877207577 | 112 | 71 | 11.5 |
| 3.5830478710159466 | 237 | 78 | 6.9 |
| 2.6207413942088964 | 224 | 67 | 13.8 |
| 2.3513346877207577 | 27 | 76 | 10.3 |
| … | … | … | … |
(plot/render-image
{:data (shingle/shingle env :radiation {:count 4 :overlap 0.5 :as :radiation-cut :label "Radiation"})
:mapping {:x :wind :y :temperature :z :ozone :facet :radiation-cut}
:charts [(chart/cloud {:size 4 :view {:azimuth -40 :elevation 30 :distance 0.2}})]
:facets {:columns 4}}
{:width 1000 :height 350})
38.6.6 Fig 6.7 Scatter-plot matrix
Source: Lattice Fig 6.7. Data: Ozone and weather, New York 1973, R lattice package environmental (Bruntz et al. 1974; Cleveland 1993); licence: GPL (>= 2) (lattice).
(plot/render-image
(plot/pairs env {:variables [:ozone :radiation :temperature :wind] :upper (chart/scatter) :diagonal :names})
{:width 650 :height 650})
38.6.7 Fig 6.8 Four models as surfaces
Ozone modelled on wind, temperature and radiation, evaluated on a wind x temperature grid at four radiation levels: a linear model with all interactions (as the book), and - in place of the book’s loess and locfit fits - a Gaussian process (kernel sigma 0.25), a radial basis function fit and Shepard interpolation (fastmath, on the predictors scaled to [0, 1]). Shepard’s inverse-distance weights use power 1 (default 2) for a smoother surface; it still passes through every observation, so the slices show small dimples where they come close to one. The view turned so the side along temperature, where ozone grows, faces us.
Source: Lattice Fig 6.8. Data: Ozone and weather, New York 1973, R lattice package environmental (Bruntz et al. 1974; Cleveland 1993); licence: GPL (>= 2) (lattice).
(def env-fits
"Fitted ozone on a 51 x 51 wind x temperature grid at 4 radiation levels, one row per model and grid point."
(let [predictors [:wind :temperature :radiation]
ranges (into {} (for [c predictors] [c [(reduce min (map c env)) (reduce max (map c env))]]))
unit (fn [point] (mapv (fn [c v] (let [[lo hi] (ranges c)] (/ (- v lo) (- hi lo)))) predictors point))
points (mapv (apply juxt predictors) env)
ozone (mapv :ozone env)
terms (fn [[w t r]] [r t w (* r t) (* r w) (* t w) (* r t w)])
linear (regression/lm ozone (mapv terms points))
gp (interp/interpolation :gp (mapv unit points) ozone (k/kernel :gaussian {:sigma 0.25}) {:noise 0.2})
rbf (interp/interpolation :rbf (mapv unit points) ozone (k/rbf :gaussian {:scale 0.4}) {:lambda 0.5})
shepard (interp/interpolation :shepard (mapv unit points) ozone {:p 1.0})
models [["linear" #(linear (terms %))] ["Gaussian process" #(gp (unit %))]
["radial basis" #(rbf (unit %))] ["Shepard" #(shepard (unit %))]]
mesh (fn [[lo hi] n] (mapv #(+ lo (* (- hi lo) (/ % (double n)))) (range (inc n))))]
(vec (for [[model f] models, r (mesh (ranges :radiation) 3), w (mesh (ranges :wind) 50), t (mesh (ranges :temperature) 50)]
{:model model :radiation (m/round r) :wind w :temperature t :fit (f [w t r])}))))| model | radiation | wind | temperature | fit |
|---|---|---|---|---|
| linear | 7 | 2.3 | 57.0 | 1.6474856063065357 |
| linear | 7 | 2.3 | 57.8 | 1.7075033244266682 |
| linear | 7 | 2.3 | 58.6 | 1.7675210425468015 |
| linear | 7 | 2.3 | 59.4 | 1.827538760666934 |
| linear | 7 | 2.3 | 60.2 | 1.8875564787870673 |
| linear | 7 | 2.3 | 61.0 | 1.947574196907199 |
| linear | 7 | 2.3 | 61.8 | 2.0075919150273314 |
| linear | 7 | 2.3 | 62.6 | 2.0676096331474647 |
| linear | 7 | 2.3 | 63.4 | 2.127627351267597 |
| linear | 7 | 2.3 | 64.2 | 2.1876450693877296 |
| linear | 7 | 2.3 | 65.0 | 2.247662787507864 |
| linear | 7 | 2.3 | 65.8 | 2.3076805056279945 |
| linear | 7 | 2.3 | 66.6 | 2.367698223748127 |
| linear | 7 | 2.3 | 67.4 | 2.4277159418682612 |
| linear | 7 | 2.3 | 68.2 | 2.4877336599883937 |
| linear | 7 | 2.3 | 69.0 | 2.547751378108527 |
| linear | 7 | 2.3 | 69.8 | 2.6077690962286577 |
| linear | 7 | 2.3 | 70.6 | 2.667786814348792 |
| linear | 7 | 2.3 | 71.4 | 2.7278045324689253 |
| linear | 7 | 2.3 | 72.2 | 2.787822250589057 |
| linear | 7 | 2.3 | 73.0 | 2.84783996870919 |
| linear | 7 | 2.3 | 73.8 | 2.9078576868293218 |
| linear | 7 | 2.3 | 74.6 | 2.9678754049494542 |
| linear | 7 | 2.3 | 75.4 | 3.0278931230695885 |
| linear | 7 | 2.3 | 76.2 | 3.08791084118972 |
| linear | 7 | 2.3 | 77.0 | 3.1479285593098534 |
| linear | 7 | 2.3 | 77.8 | 3.207946277429986 |
| linear | 7 | 2.3 | 78.6 | 3.2679639955501174 |
| linear | 7 | 2.3 | 79.4 | 3.3279817136702516 |
| linear | 7 | 2.3 | 80.2 | 3.387999431790384 |
| linear | 7 | 2.3 | 81.0 | 3.4480171499105157 |
| linear | 7 | 2.3 | 81.8 | 3.508034868030649 |
| linear | 7 | 2.3 | 82.6 | 3.5680525861507806 |
| linear | 7 | 2.3 | 83.4 | 3.628070304270914 |
| linear | 7 | 2.3 | 84.2 | 3.6880880223910464 |
| linear | 7 | 2.3 | 85.0 | 3.748105740511179 |
| linear | 7 | 2.3 | 85.8 | 3.8081234586313113 |
| linear | 7 | 2.3 | 86.6 | 3.868141176751443 |
| linear | 7 | 2.3 | 87.4 | 3.928158894871577 |
| linear | 7 | 2.3 | 88.2 | 3.9881766129917113 |
| linear | 7 | 2.3 | 89.0 | 4.0481943311118425 |
| linear | 7 | 2.3 | 89.8 | 4.108212049231975 |
| linear | 7 | 2.3 | 90.6 | 4.168229767352107 |
| linear | 7 | 2.3 | 91.4 | 4.228247485472242 |
| linear | 7 | 2.3 | 92.2 | 4.288265203592376 |
| linear | 7 | 2.3 | 93.0 | 4.348282921712505 |
| linear | 7 | 2.3 | 93.80000000000001 | 4.408300639832637 |
| linear | 7 | 2.3 | 94.6 | 4.46831835795277 |
| linear | 7 | 2.3 | 95.4 | 4.528336076072904 |
| linear | 7 | 2.3 | 96.2 | 4.588353794193036 |
| linear | 7 | 2.3 | 97.0 | 4.648371512313167 |
| linear | 7 | 2.6679999999999997 | 57.0 | 1.6593064909981021 |
| linear | 7 | 2.6679999999999997 | 57.8 | 1.7178677552849915 |
| linear | 7 | 2.6679999999999997 | 58.6 | 1.7764290195718808 |
| linear | 7 | 2.6679999999999997 | 59.4 | 1.8349902838587684 |
| linear | 7 | 2.6679999999999997 | 60.2 | 1.8935515481456586 |
| linear | 7 | 2.6679999999999997 | 61.0 | 1.9521128124325462 |
| linear | 7 | 2.6679999999999997 | 61.8 | 2.0106740767194347 |
| linear | 7 | 2.6679999999999997 | 62.6 | 2.069235341006324 |
| linear | 7 | 2.6679999999999997 | 63.4 | 2.1277966052932116 |
| linear | 7 | 2.6679999999999997 | 64.2 | 2.186357869580101 |
| linear | 7 | 2.6679999999999997 | 65.0 | 2.2449191338669903 |
| linear | 7 | 2.6679999999999997 | 65.8 | 2.303480398153877 |
| linear | 7 | 2.6679999999999997 | 66.6 | 2.3620416624407663 |
| linear | 7 | 2.6679999999999997 | 67.4 | 2.4206029267276565 |
| linear | 7 | 2.6679999999999997 | 68.2 | 2.479164191014544 |
| linear | 7 | 2.6679999999999997 | 69.0 | 2.5377254553014335 |
| linear | 7 | 2.6679999999999997 | 69.8 | 2.596286719588321 |
| linear | 7 | 2.6679999999999997 | 70.6 | 2.6548479838752104 |
| linear | 7 | 2.6679999999999997 | 71.4 | 2.7134092481621006 |
| linear | 7 | 2.6679999999999997 | 72.2 | 2.771970512448989 |
| linear | 7 | 2.6679999999999997 | 73.0 | 2.8305317767358775 |
| linear | 7 | 2.6679999999999997 | 73.8 | 2.889093041022765 |
| linear | 7 | 2.6679999999999997 | 74.6 | 2.9476543053096544 |
| linear | 7 | 2.6679999999999997 | 75.4 | 3.006215569596544 |
| linear | 7 | 2.6679999999999997 | 76.2 | 3.0647768338834322 |
| linear | 7 | 2.6679999999999997 | 77.0 | 3.1233380981703216 |
| linear | 7 | 2.6679999999999997 | 77.8 | 3.181899362457209 |
| linear | 7 | 2.6679999999999997 | 78.6 | 3.2404606267440976 |
| linear | 7 | 2.6679999999999997 | 79.4 | 3.299021891030987 |
| linear | 7 | 2.6679999999999997 | 80.2 | 3.3575831553178754 |
| linear | 7 | 2.6679999999999997 | 81.0 | 3.416144419604764 |
| linear | 7 | 2.6679999999999997 | 81.8 | 3.4747056838916524 |
| linear | 7 | 2.6679999999999997 | 82.6 | 3.533266948178541 |
| linear | 7 | 2.6679999999999997 | 83.4 | 3.591828212465431 |
| linear | 7 | 2.6679999999999997 | 84.2 | 3.6503894767523195 |
| linear | 7 | 2.6679999999999997 | 85.0 | 3.708950741039207 |
| linear | 7 | 2.6679999999999997 | 85.8 | 3.7675120053260955 |
| linear | 7 | 2.6679999999999997 | 86.6 | 3.826073269612983 |
| linear | 7 | 2.6679999999999997 | 87.4 | 3.8846345338998733 |
| linear | 7 | 2.6679999999999997 | 88.2 | 3.9431957981867645 |
| linear | 7 | 2.6679999999999997 | 89.0 | 4.0017570624736525 |
| linear | 7 | 2.6679999999999997 | 89.8 | 4.060318326760541 |
| linear | 7 | 2.6679999999999997 | 90.6 | 4.118879591047429 |
| linear | 7 | 2.6679999999999997 | 91.4 | 4.177440855334318 |
| linear | 7 | 2.6679999999999997 | 92.2 | 4.236002119621208 |
| linear | 7 | 2.6679999999999997 | 93.0 | 4.294563383908095 |
| linear | 7 | 2.6679999999999997 | 93.80000000000001 | 4.353124648194983 |
| linear | 7 | 2.6679999999999997 | 94.6 | 4.411685912481872 |
| linear | 7 | 2.6679999999999997 | 95.4 | 4.47024717676876 |
| … | … | … | … | … |
(def model-order {:facet-row {:domain ["Shepard" "radial basis" "Gaussian process" "linear"]}})(plot/render-image
{:data env-fits
:mapping {:x :wind :y :temperature :z :fit :facet-col :radiation :facet-row :model}
:scales model-order
:charts [(chart/surface {:view {:azimuth -40 :elevation 30 :distance 0.2} :axes false})]}
{:width 900 :height 800})
38.6.8 Fig 6.9 The same models as level plots
Source: Lattice Fig 6.9. Data: Ozone and weather, New York 1973, R lattice package environmental (Bruntz et al. 1974; Cleveland 1993); licence: GPL (>= 2) (lattice).
(plot/render-image
{:data env-fits
:mapping {:x :wind :y :temperature :value :fit :facet-col :radiation :facet-row :model}
:scales model-order
:charts [(chart/field)]
:labels {:x "wind" :y "temperature"}}
{:width 900 :height 800})
38.6.9 Fig 6.10 Labelled contours
The Gaussian process fit (in place of the book’s locfit) as contour lines with their levels, a panel per radiation level - the highest on top, as the book’s bottom-up panels.
Source: Lattice Fig 6.10. Data: Ozone and weather, New York 1973, R lattice package environmental (Bruntz et al. 1974; Cleveland 1993); licence: GPL (>= 2) (lattice).
(plot/render-image
{:data (filterv #(= "Gaussian process" (:model %)) env-fits)
:mapping {:x :wind :y :temperature :value :fit :facet :radiation}
:scales {:facet {:order-by #(:radiation (first %)) :descending true}}
:charts [(chart/contour {:levels 15 :labels true :color [40 40 40]})]
:facets {:columns 1}
:labels {:x "wind" :y "temperature"}}
{:width 500 :height 800})
38.6.10 Fig 6.11 Volcano three ways
The Maunga Whau volcano (a 10 m grid of heights) as a level plot, as contours, as a wireframe.
Source: Lattice Fig 6.11. Data: Maunga Whau volcano topography, R datasets package volcano (Ross Ihaka); licence: Part of R (GPL-2 | GPL-3).
(def volcano (nu/dataset :volcano))| row | column | height |
|---|---|---|
| 1 | 1 | 100 |
| 2 | 1 | 101 |
| 3 | 1 | 102 |
| 4 | 1 | 103 |
| 5 | 1 | 104 |
| 6 | 1 | 105 |
| 7 | 1 | 105 |
| 8 | 1 | 106 |
| 9 | 1 | 107 |
| 10 | 1 | 108 |
| 11 | 1 | 109 |
| 12 | 1 | 110 |
| 13 | 1 | 110 |
| 14 | 1 | 111 |
| 15 | 1 | 114 |
| 16 | 1 | 116 |
| 17 | 1 | 118 |
| 18 | 1 | 120 |
| 19 | 1 | 120 |
| 20 | 1 | 121 |
| 21 | 1 | 122 |
| 22 | 1 | 122 |
| 23 | 1 | 123 |
| 24 | 1 | 124 |
| 25 | 1 | 123 |
| 26 | 1 | 123 |
| 27 | 1 | 120 |
| 28 | 1 | 118 |
| 29 | 1 | 117 |
| 30 | 1 | 115 |
| 31 | 1 | 114 |
| 32 | 1 | 115 |
| 33 | 1 | 113 |
| 34 | 1 | 111 |
| 35 | 1 | 110 |
| 36 | 1 | 109 |
| 37 | 1 | 108 |
| 38 | 1 | 108 |
| 39 | 1 | 107 |
| 40 | 1 | 107 |
| 41 | 1 | 107 |
| 42 | 1 | 108 |
| 43 | 1 | 109 |
| 44 | 1 | 110 |
| 45 | 1 | 111 |
| 46 | 1 | 111 |
| 47 | 1 | 112 |
| 48 | 1 | 113 |
| 49 | 1 | 113 |
| 50 | 1 | 114 |
| 51 | 1 | 115 |
| 52 | 1 | 115 |
| 53 | 1 | 114 |
| 54 | 1 | 113 |
| 55 | 1 | 112 |
| 56 | 1 | 111 |
| 57 | 1 | 111 |
| 58 | 1 | 112 |
| 59 | 1 | 112 |
| 60 | 1 | 112 |
| 61 | 1 | 113 |
| 62 | 1 | 114 |
| 63 | 1 | 114 |
| 64 | 1 | 115 |
| 65 | 1 | 115 |
| 66 | 1 | 116 |
| 67 | 1 | 116 |
| 68 | 1 | 117 |
| 69 | 1 | 117 |
| 70 | 1 | 116 |
| 71 | 1 | 114 |
| 72 | 1 | 112 |
| 73 | 1 | 109 |
| 74 | 1 | 106 |
| 75 | 1 | 104 |
| 76 | 1 | 102 |
| 77 | 1 | 101 |
| 78 | 1 | 100 |
| 79 | 1 | 100 |
| 80 | 1 | 99 |
| 81 | 1 | 99 |
| 82 | 1 | 99 |
| 83 | 1 | 99 |
| 84 | 1 | 98 |
| 85 | 1 | 98 |
| 86 | 1 | 97 |
| 87 | 1 | 97 |
| 1 | 2 | 100 |
| 2 | 2 | 101 |
| 3 | 2 | 102 |
| 4 | 2 | 103 |
| 5 | 2 | 104 |
| 6 | 2 | 105 |
| 7 | 2 | 106 |
| 8 | 2 | 107 |
| 9 | 2 | 108 |
| 10 | 2 | 109 |
| 11 | 2 | 110 |
| 12 | 2 | 110 |
| 13 | 2 | 111 |
| … | … | … |
(plot/render-image
(plot/arrange [{:data volcano
:mapping {:x :row :y :column :value :height}
:charts [(chart/field)]
:aspect :iso}
{:data volcano
:mapping {:x :row :y :column :value :height}
:charts [(chart/contour {:levels 20 :color :black})]
:aspect :iso}
{:data volcano
:mapping {:x :row :y :column :z :height}
:charts [(chart/surface {:style :wireframe :view {:azimuth -40 :elevation 30 :distance 0.2}
:color :black :stroke-width 0.3 :aspect [1 0.7 0.5]
:axis-titles {:x "row" :y "column" :z "volcano"}})]}]
{:columns 1 :heights [1 1 1.6]})
{:width 600 :height 800})
38.6.11 Fig 6.12 A correlation matrix
Pairwise correlations of the numeric columns of the 1993 cars (complete pairs).
Source: Lattice Fig 6.12. Data: Cars on sale in the USA, 1993, R MASS package Cars93 (Lock 1993); licence: GPL-2 | GPL-3 (MASS).
(def cars93 (nu/dataset :cars93))| manufacturer | model | type | min-price | price | max-price | mpg-city | mpg-highway | air-bags | drive-train | cylinders | engine-size | horsepower | rpm | rev-per-mile | man-trans-avail | fuel-tank-capacity | passengers | length | wheelbase | width | turn-circle | rear-seat-room | luggage-room | weight | origin | make |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Acura | Integra | Small | 12.9 | 15.9 | 18.8 | 25 | 31 | None | Front | 4 | 1.8 | 140 | 6300 | 2890 | Yes | 13.2 | 5 | 177 | 102 | 68 | 37 | 26.5 | 11 | 2705 | non-USA | Acura Integra |
| Acura | Legend | Midsize | 29.2 | 33.9 | 38.7 | 18 | 25 | Driver & Passenger | Front | 6 | 3.2 | 200 | 5500 | 2335 | Yes | 18 | 5 | 195 | 115 | 71 | 38 | 30 | 15 | 3560 | non-USA | Acura Legend |
| Audi | 90 | Compact | 25.9 | 29.1 | 32.3 | 20 | 26 | Driver only | Front | 6 | 2.8 | 172 | 5500 | 2280 | Yes | 16.9 | 5 | 180 | 102 | 67 | 37 | 28 | 14 | 3375 | non-USA | Audi 90 |
| Audi | 100 | Midsize | 30.8 | 37.7 | 44.6 | 19 | 26 | Driver & Passenger | Front | 6 | 2.8 | 172 | 5500 | 2535 | Yes | 21.1 | 6 | 193 | 106 | 70 | 37 | 31 | 17 | 3405 | non-USA | Audi 100 |
| BMW | 535i | Midsize | 23.7 | 30 | 36.2 | 22 | 30 | Driver only | Rear | 4 | 3.5 | 208 | 5700 | 2545 | Yes | 21.1 | 4 | 186 | 109 | 69 | 39 | 27 | 13 | 3640 | non-USA | BMW 535i |
| Buick | Century | Midsize | 14.2 | 15.7 | 17.3 | 22 | 31 | Driver only | Front | 4 | 2.2 | 110 | 5200 | 2565 | No | 16.4 | 6 | 189 | 105 | 69 | 41 | 28 | 16 | 2880 | USA | Buick Century |
| Buick | LeSabre | Large | 19.9 | 20.8 | 21.7 | 19 | 28 | Driver only | Front | 6 | 3.8 | 170 | 4800 | 1570 | No | 18 | 6 | 200 | 111 | 74 | 42 | 30.5 | 17 | 3470 | USA | Buick LeSabre |
| Buick | Roadmaster | Large | 22.6 | 23.7 | 24.9 | 16 | 25 | Driver only | Rear | 6 | 5.7 | 180 | 4000 | 1320 | No | 23 | 6 | 216 | 116 | 78 | 45 | 30.5 | 21 | 4105 | USA | Buick Roadmaster |
| Buick | Riviera | Midsize | 26.3 | 26.3 | 26.3 | 19 | 27 | Driver only | Front | 6 | 3.8 | 170 | 4800 | 1690 | No | 18.8 | 5 | 198 | 108 | 73 | 41 | 26.5 | 14 | 3495 | USA | Buick Riviera |
| Cadillac | DeVille | Large | 33 | 34.7 | 36.3 | 16 | 25 | Driver only | Front | 8 | 4.9 | 200 | 4100 | 1510 | No | 18 | 6 | 206 | 114 | 73 | 43 | 35 | 18 | 3620 | USA | Cadillac DeVille |
| Cadillac | Seville | Midsize | 37.5 | 40.1 | 42.7 | 16 | 25 | Driver & Passenger | Front | 8 | 4.6 | 295 | 6000 | 1985 | No | 20 | 5 | 204 | 111 | 74 | 44 | 31 | 14 | 3935 | USA | Cadillac Seville |
| Chevrolet | Cavalier | Compact | 8.5 | 13.4 | 18.3 | 25 | 36 | None | Front | 4 | 2.2 | 110 | 5200 | 2380 | Yes | 15.2 | 5 | 182 | 101 | 66 | 38 | 25 | 13 | 2490 | USA | Chevrolet Cavalier |
| Chevrolet | Corsica | Compact | 11.4 | 11.4 | 11.4 | 25 | 34 | Driver only | Front | 4 | 2.2 | 110 | 5200 | 2665 | Yes | 15.6 | 5 | 184 | 103 | 68 | 39 | 26 | 14 | 2785 | USA | Chevrolet Corsica |
| Chevrolet | Camaro | Sporty | 13.4 | 15.1 | 16.8 | 19 | 28 | Driver & Passenger | Rear | 6 | 3.4 | 160 | 4600 | 1805 | Yes | 15.5 | 4 | 193 | 101 | 74 | 43 | 25 | 13 | 3240 | USA | Chevrolet Camaro |
| Chevrolet | Lumina | Midsize | 13.4 | 15.9 | 18.4 | 21 | 29 | None | Front | 4 | 2.2 | 110 | 5200 | 2595 | No | 16.5 | 6 | 198 | 108 | 71 | 40 | 28.5 | 16 | 3195 | USA | Chevrolet Lumina |
| Chevrolet | Lumina_APV | Van | 14.7 | 16.3 | 18 | 18 | 23 | None | Front | 6 | 3.8 | 170 | 4800 | 1690 | No | 20 | 7 | 178 | 110 | 74 | 44 | 30.5 | 3715 | USA | Chevrolet Lumina_APV | |
| Chevrolet | Astro | Van | 14.7 | 16.6 | 18.6 | 15 | 20 | None | 4WD | 6 | 4.3 | 165 | 4000 | 1790 | No | 27 | 8 | 194 | 111 | 78 | 42 | 33.5 | 4025 | USA | Chevrolet Astro | |
| Chevrolet | Caprice | Large | 18 | 18.8 | 19.6 | 17 | 26 | Driver only | Rear | 8 | 5 | 170 | 4200 | 1350 | No | 23 | 6 | 214 | 116 | 77 | 42 | 29.5 | 20 | 3910 | USA | Chevrolet Caprice |
| Chevrolet | Corvette | Sporty | 34.6 | 38 | 41.5 | 17 | 25 | Driver only | Rear | 8 | 5.7 | 300 | 5000 | 1450 | Yes | 20 | 2 | 179 | 96 | 74 | 43 | 3380 | USA | Chevrolet Corvette | ||
| Chrylser | Concorde | Large | 18.4 | 18.4 | 18.4 | 20 | 28 | Driver & Passenger | Front | 6 | 3.3 | 153 | 5300 | 1990 | No | 18 | 6 | 203 | 113 | 74 | 40 | 31 | 15 | 3515 | USA | Chrylser Concorde |
| Chrysler | LeBaron | Compact | 14.5 | 15.8 | 17.1 | 23 | 28 | Driver & Passenger | Front | 4 | 3 | 141 | 5000 | 2090 | No | 16 | 6 | 183 | 104 | 68 | 41 | 30.5 | 14 | 3085 | USA | Chrysler LeBaron |
| Chrysler | Imperial | Large | 29.5 | 29.5 | 29.5 | 20 | 26 | Driver only | Front | 6 | 3.3 | 147 | 4800 | 1785 | No | 16 | 6 | 203 | 110 | 69 | 44 | 36 | 17 | 3570 | USA | Chrysler Imperial |
| Dodge | Colt | Small | 7.9 | 9.2 | 10.6 | 29 | 33 | None | Front | 4 | 1.5 | 92 | 6000 | 3285 | Yes | 13.2 | 5 | 174 | 98 | 66 | 32 | 26.5 | 11 | 2270 | USA | Dodge Colt |
| Dodge | Shadow | Small | 8.4 | 11.3 | 14.2 | 23 | 29 | Driver only | Front | 4 | 2.2 | 93 | 4800 | 2595 | Yes | 14 | 5 | 172 | 97 | 67 | 38 | 26.5 | 13 | 2670 | USA | Dodge Shadow |
| Dodge | Spirit | Compact | 11.9 | 13.3 | 14.7 | 22 | 27 | Driver only | Front | 4 | 2.5 | 100 | 4800 | 2535 | Yes | 16 | 6 | 181 | 104 | 68 | 39 | 30.5 | 14 | 2970 | USA | Dodge Spirit |
| Dodge | Caravan | Van | 13.6 | 19 | 24.4 | 17 | 21 | Driver only | 4WD | 6 | 3 | 142 | 5000 | 1970 | No | 20 | 7 | 175 | 112 | 72 | 42 | 26.5 | 3705 | USA | Dodge Caravan | |
| Dodge | Dynasty | Midsize | 14.8 | 15.6 | 16.4 | 21 | 27 | Driver only | Front | 4 | 2.5 | 100 | 4800 | 2465 | No | 16 | 6 | 192 | 105 | 69 | 42 | 30.5 | 16 | 3080 | USA | Dodge Dynasty |
| Dodge | Stealth | Sporty | 18.5 | 25.8 | 33.1 | 18 | 24 | Driver only | 4WD | 6 | 3 | 300 | 6000 | 2120 | Yes | 19.8 | 4 | 180 | 97 | 72 | 40 | 20 | 11 | 3805 | USA | Dodge Stealth |
| Eagle | Summit | Small | 7.9 | 12.2 | 16.5 | 29 | 33 | None | Front | 4 | 1.5 | 92 | 6000 | 2505 | Yes | 13.2 | 5 | 174 | 98 | 66 | 36 | 26.5 | 11 | 2295 | USA | Eagle Summit |
| Eagle | Vision | Large | 17.5 | 19.3 | 21.2 | 20 | 28 | Driver & Passenger | Front | 6 | 3.5 | 214 | 5800 | 1980 | No | 18 | 6 | 202 | 113 | 74 | 40 | 30 | 15 | 3490 | USA | Eagle Vision |
| Ford | Festiva | Small | 6.9 | 7.4 | 7.9 | 31 | 33 | None | Front | 4 | 1.3 | 63 | 5000 | 3150 | Yes | 10 | 4 | 141 | 90 | 63 | 33 | 26 | 12 | 1845 | USA | Ford Festiva |
| Ford | Escort | Small | 8.4 | 10.1 | 11.9 | 23 | 30 | None | Front | 4 | 1.8 | 127 | 6500 | 2410 | Yes | 13.2 | 5 | 171 | 98 | 67 | 36 | 28 | 12 | 2530 | USA | Ford Escort |
| Ford | Tempo | Compact | 10.4 | 11.3 | 12.2 | 22 | 27 | None | Front | 4 | 2.3 | 96 | 4200 | 2805 | Yes | 15.9 | 5 | 177 | 100 | 68 | 39 | 27.5 | 13 | 2690 | USA | Ford Tempo |
| Ford | Mustang | Sporty | 10.8 | 15.9 | 21 | 22 | 29 | Driver only | Rear | 4 | 2.3 | 105 | 4600 | 2285 | Yes | 15.4 | 4 | 180 | 101 | 68 | 40 | 24 | 12 | 2850 | USA | Ford Mustang |
| Ford | Probe | Sporty | 12.8 | 14 | 15.2 | 24 | 30 | Driver only | Front | 4 | 2 | 115 | 5500 | 2340 | Yes | 15.5 | 4 | 179 | 103 | 70 | 38 | 23 | 18 | 2710 | USA | Ford Probe |
| Ford | Aerostar | Van | 14.5 | 19.9 | 25.3 | 15 | 20 | Driver only | 4WD | 6 | 3 | 145 | 4800 | 2080 | Yes | 21 | 7 | 176 | 119 | 72 | 45 | 30 | 3735 | USA | Ford Aerostar | |
| Ford | Taurus | Midsize | 15.6 | 20.2 | 24.8 | 21 | 30 | Driver only | Front | 6 | 3 | 140 | 4800 | 1885 | No | 16 | 5 | 192 | 106 | 71 | 40 | 27.5 | 18 | 3325 | USA | Ford Taurus |
| Ford | Crown_Victoria | Large | 20.1 | 20.9 | 21.7 | 18 | 26 | Driver only | Rear | 8 | 4.6 | 190 | 4200 | 1415 | No | 20 | 6 | 212 | 114 | 78 | 43 | 30 | 21 | 3950 | USA | Ford Crown_Victoria |
| Geo | Metro | Small | 6.7 | 8.4 | 10 | 46 | 50 | None | Front | 3 | 1 | 55 | 5700 | 3755 | Yes | 10.6 | 4 | 151 | 93 | 63 | 34 | 27.5 | 10 | 1695 | non-USA | Geo Metro |
| Geo | Storm | Sporty | 11.5 | 12.5 | 13.5 | 30 | 36 | Driver only | Front | 4 | 1.6 | 90 | 5400 | 3250 | Yes | 12.4 | 4 | 164 | 97 | 67 | 37 | 24.5 | 11 | 2475 | non-USA | Geo Storm |
| Honda | Prelude | Sporty | 17 | 19.8 | 22.7 | 24 | 31 | Driver & Passenger | Front | 4 | 2.3 | 160 | 5800 | 2855 | Yes | 15.9 | 4 | 175 | 100 | 70 | 39 | 23.5 | 8 | 2865 | non-USA | Honda Prelude |
| Honda | Civic | Small | 8.4 | 12.1 | 15.8 | 42 | 46 | Driver only | Front | 4 | 1.5 | 102 | 5900 | 2650 | Yes | 11.9 | 4 | 173 | 103 | 67 | 36 | 28 | 12 | 2350 | non-USA | Honda Civic |
| Honda | Accord | Compact | 13.8 | 17.5 | 21.2 | 24 | 31 | Driver & Passenger | Front | 4 | 2.2 | 140 | 5600 | 2610 | Yes | 17 | 4 | 185 | 107 | 67 | 41 | 28 | 14 | 3040 | non-USA | Honda Accord |
| Hyundai | Excel | Small | 6.8 | 8 | 9.2 | 29 | 33 | None | Front | 4 | 1.5 | 81 | 5500 | 2710 | Yes | 11.9 | 5 | 168 | 94 | 63 | 35 | 26 | 11 | 2345 | non-USA | Hyundai Excel |
| Hyundai | Elantra | Small | 9 | 10 | 11 | 22 | 29 | None | Front | 4 | 1.8 | 124 | 6000 | 2745 | Yes | 13.7 | 5 | 172 | 98 | 66 | 36 | 28 | 12 | 2620 | non-USA | Hyundai Elantra |
| Hyundai | Scoupe | Sporty | 9.1 | 10 | 11 | 26 | 34 | None | Front | 4 | 1.5 | 92 | 5550 | 2540 | Yes | 11.9 | 4 | 166 | 94 | 64 | 34 | 23.5 | 9 | 2285 | non-USA | Hyundai Scoupe |
| Hyundai | Sonata | Midsize | 12.4 | 13.9 | 15.3 | 20 | 27 | None | Front | 4 | 2 | 128 | 6000 | 2335 | Yes | 17.2 | 5 | 184 | 104 | 69 | 41 | 31 | 14 | 2885 | non-USA | Hyundai Sonata |
| Infiniti | Q45 | Midsize | 45.4 | 47.9 | 50.4 | 17 | 22 | Driver only | Rear | 8 | 4.5 | 278 | 6000 | 1955 | No | 22.5 | 5 | 200 | 113 | 72 | 42 | 29 | 15 | 4000 | non-USA | Infiniti Q45 |
| Lexus | ES300 | Midsize | 27.5 | 28 | 28.4 | 18 | 24 | Driver only | Front | 6 | 3 | 185 | 5200 | 2325 | Yes | 18.5 | 5 | 188 | 103 | 70 | 40 | 27.5 | 14 | 3510 | non-USA | Lexus ES300 |
| Lexus | SC300 | Midsize | 34.7 | 35.2 | 35.6 | 18 | 23 | Driver & Passenger | Rear | 6 | 3 | 225 | 6000 | 2510 | Yes | 20.6 | 4 | 191 | 106 | 71 | 39 | 25 | 9 | 3515 | non-USA | Lexus SC300 |
| Lincoln | Continental | Midsize | 33.3 | 34.3 | 35.3 | 17 | 26 | Driver & Passenger | Front | 6 | 3.8 | 160 | 4400 | 1835 | No | 18.4 | 6 | 205 | 109 | 73 | 42 | 30 | 19 | 3695 | USA | Lincoln Continental |
| Lincoln | Town_Car | Large | 34.4 | 36.1 | 37.8 | 18 | 26 | Driver & Passenger | Rear | 8 | 4.6 | 210 | 4600 | 1840 | No | 20 | 6 | 219 | 117 | 77 | 45 | 31.5 | 22 | 4055 | USA | Lincoln Town_Car |
| Mazda | 323 | Small | 7.4 | 8.3 | 9.1 | 29 | 37 | None | Front | 4 | 1.6 | 82 | 5000 | 2370 | Yes | 13.2 | 4 | 164 | 97 | 66 | 34 | 27 | 16 | 2325 | non-USA | Mazda 323 |
| Mazda | Protege | Small | 10.9 | 11.6 | 12.3 | 28 | 36 | None | Front | 4 | 1.8 | 103 | 5500 | 2220 | Yes | 14.5 | 5 | 172 | 98 | 66 | 36 | 26.5 | 13 | 2440 | non-USA | Mazda Protege |
| Mazda | 626 | Compact | 14.3 | 16.5 | 18.7 | 26 | 34 | Driver only | Front | 4 | 2.5 | 164 | 5600 | 2505 | Yes | 15.5 | 5 | 184 | 103 | 69 | 40 | 29.5 | 14 | 2970 | non-USA | Mazda 626 |
| Mazda | MPV | Van | 16.6 | 19.1 | 21.7 | 18 | 24 | None | 4WD | 6 | 3 | 155 | 5000 | 2240 | No | 19.6 | 7 | 190 | 110 | 72 | 39 | 27.5 | 3735 | non-USA | Mazda MPV | |
| Mazda | RX-7 | Sporty | 32.5 | 32.5 | 32.5 | 17 | 25 | Driver only | Rear | rotary | 1.3 | 255 | 6500 | 2325 | Yes | 20 | 2 | 169 | 96 | 69 | 37 | 2895 | non-USA | Mazda RX-7 | ||
| Mercedes-Benz | 190E | Compact | 29 | 31.9 | 34.9 | 20 | 29 | Driver only | Rear | 4 | 2.3 | 130 | 5100 | 2425 | Yes | 14.5 | 5 | 175 | 105 | 67 | 34 | 26 | 12 | 2920 | non-USA | Mercedes-Benz 190E |
| Mercedes-Benz | 300E | Midsize | 43.8 | 61.9 | 80 | 19 | 25 | Driver & Passenger | Rear | 6 | 3.2 | 217 | 5500 | 2220 | No | 18.5 | 5 | 187 | 110 | 69 | 37 | 27 | 15 | 3525 | non-USA | Mercedes-Benz 300E |
| Mercury | Capri | Sporty | 13.3 | 14.1 | 15 | 23 | 26 | Driver only | Front | 4 | 1.6 | 100 | 5750 | 2475 | Yes | 11.1 | 4 | 166 | 95 | 65 | 36 | 19 | 6 | 2450 | USA | Mercury Capri |
| Mercury | Cougar | Midsize | 14.9 | 14.9 | 14.9 | 19 | 26 | None | Rear | 6 | 3.8 | 140 | 3800 | 1730 | No | 18 | 5 | 199 | 113 | 73 | 38 | 28 | 15 | 3610 | USA | Mercury Cougar |
| Mitsubishi | Mirage | Small | 7.7 | 10.3 | 12.9 | 29 | 33 | None | Front | 4 | 1.5 | 92 | 6000 | 2505 | Yes | 13.2 | 5 | 172 | 98 | 67 | 36 | 26 | 11 | 2295 | non-USA | Mitsubishi Mirage |
| Mitsubishi | Diamante | Midsize | 22.4 | 26.1 | 29.9 | 18 | 24 | Driver only | Front | 6 | 3 | 202 | 6000 | 2210 | No | 19 | 5 | 190 | 107 | 70 | 43 | 27.5 | 14 | 3730 | non-USA | Mitsubishi Diamante |
| Nissan | Sentra | Small | 8.7 | 11.8 | 14.9 | 29 | 33 | Driver only | Front | 4 | 1.6 | 110 | 6000 | 2435 | Yes | 13.2 | 5 | 170 | 96 | 66 | 33 | 26 | 12 | 2545 | non-USA | Nissan Sentra |
| Nissan | Altima | Compact | 13 | 15.7 | 18.3 | 24 | 30 | Driver only | Front | 4 | 2.4 | 150 | 5600 | 2130 | Yes | 15.9 | 5 | 181 | 103 | 67 | 40 | 28.5 | 14 | 3050 | non-USA | Nissan Altima |
| Nissan | Quest | Van | 16.7 | 19.1 | 21.5 | 17 | 23 | None | Front | 6 | 3 | 151 | 4800 | 2065 | No | 20 | 7 | 190 | 112 | 74 | 41 | 27 | 4100 | non-USA | Nissan Quest | |
| Nissan | Maxima | Midsize | 21 | 21.5 | 22 | 21 | 26 | Driver only | Front | 6 | 3 | 160 | 5200 | 2045 | No | 18.5 | 5 | 188 | 104 | 69 | 41 | 28.5 | 14 | 3200 | non-USA | Nissan Maxima |
| Oldsmobile | Achieva | Compact | 13 | 13.5 | 14 | 24 | 31 | None | Front | 4 | 2.3 | 155 | 6000 | 2380 | No | 15.2 | 5 | 188 | 103 | 67 | 39 | 28 | 14 | 2910 | USA | Oldsmobile Achieva |
| Oldsmobile | Cutlass_Ciera | Midsize | 14.2 | 16.3 | 18.4 | 23 | 31 | Driver only | Front | 4 | 2.2 | 110 | 5200 | 2565 | No | 16.5 | 5 | 190 | 105 | 70 | 42 | 28 | 16 | 2890 | USA | Oldsmobile Cutlass_Ciera |
| Oldsmobile | Silhouette | Van | 19.5 | 19.5 | 19.5 | 18 | 23 | None | Front | 6 | 3.8 | 170 | 4800 | 1690 | No | 20 | 7 | 194 | 110 | 74 | 44 | 30.5 | 3715 | USA | Oldsmobile Silhouette | |
| Oldsmobile | Eighty-Eight | Large | 19.5 | 20.7 | 21.9 | 19 | 28 | Driver only | Front | 6 | 3.8 | 170 | 4800 | 1570 | No | 18 | 6 | 201 | 111 | 74 | 42 | 31.5 | 17 | 3470 | USA | Oldsmobile Eighty-Eight |
| Plymouth | Laser | Sporty | 11.4 | 14.4 | 17.4 | 23 | 30 | None | 4WD | 4 | 1.8 | 92 | 5000 | 2360 | Yes | 15.9 | 4 | 173 | 97 | 67 | 39 | 24.5 | 8 | 2640 | USA | Plymouth Laser |
| Pontiac | LeMans | Small | 8.2 | 9 | 9.9 | 31 | 41 | None | Front | 4 | 1.6 | 74 | 5600 | 3130 | Yes | 13.2 | 4 | 177 | 99 | 66 | 35 | 25.5 | 17 | 2350 | USA | Pontiac LeMans |
| Pontiac | Sunbird | Compact | 9.4 | 11.1 | 12.8 | 23 | 31 | None | Front | 4 | 2 | 110 | 5200 | 2665 | Yes | 15.2 | 5 | 181 | 101 | 66 | 39 | 25 | 13 | 2575 | USA | Pontiac Sunbird |
| Pontiac | Firebird | Sporty | 14 | 17.7 | 21.4 | 19 | 28 | Driver & Passenger | Rear | 6 | 3.4 | 160 | 4600 | 1805 | Yes | 15.5 | 4 | 196 | 101 | 75 | 43 | 25 | 13 | 3240 | USA | Pontiac Firebird |
| Pontiac | Grand_Prix | Midsize | 15.4 | 18.5 | 21.6 | 19 | 27 | None | Front | 6 | 3.4 | 200 | 5000 | 1890 | Yes | 16.5 | 5 | 195 | 108 | 72 | 41 | 28.5 | 16 | 3450 | USA | Pontiac Grand_Prix |
| Pontiac | Bonneville | Large | 19.4 | 24.4 | 29.4 | 19 | 28 | Driver & Passenger | Front | 6 | 3.8 | 170 | 4800 | 1565 | No | 18 | 6 | 177 | 111 | 74 | 43 | 30.5 | 18 | 3495 | USA | Pontiac Bonneville |
| Saab | 900 | Compact | 20.3 | 28.7 | 37.1 | 20 | 26 | Driver only | Front | 4 | 2.1 | 140 | 6000 | 2910 | Yes | 18 | 5 | 184 | 99 | 67 | 37 | 26.5 | 14 | 2775 | non-USA | Saab 900 |
| Saturn | SL | Small | 9.2 | 11.1 | 12.9 | 28 | 38 | Driver only | Front | 4 | 1.9 | 85 | 5000 | 2145 | Yes | 12.8 | 5 | 176 | 102 | 68 | 40 | 26.5 | 12 | 2495 | USA | Saturn SL |
| Subaru | Justy | Small | 7.3 | 8.4 | 9.5 | 33 | 37 | None | 4WD | 3 | 1.2 | 73 | 5600 | 2875 | Yes | 9.2 | 4 | 146 | 90 | 60 | 32 | 23.5 | 10 | 2045 | non-USA | Subaru Justy |
| Subaru | Loyale | Small | 10.5 | 10.9 | 11.3 | 25 | 30 | None | 4WD | 4 | 1.8 | 90 | 5200 | 3375 | Yes | 15.9 | 5 | 175 | 97 | 65 | 35 | 27.5 | 15 | 2490 | non-USA | Subaru Loyale |
| Subaru | Legacy | Compact | 16.3 | 19.5 | 22.7 | 23 | 30 | Driver only | 4WD | 4 | 2.2 | 130 | 5600 | 2330 | Yes | 15.9 | 5 | 179 | 102 | 67 | 37 | 27 | 14 | 3085 | non-USA | Subaru Legacy |
| Suzuki | Swift | Small | 7.3 | 8.6 | 10 | 39 | 43 | None | Front | 3 | 1.3 | 70 | 6000 | 3360 | Yes | 10.6 | 4 | 161 | 93 | 63 | 34 | 27.5 | 10 | 1965 | non-USA | Suzuki Swift |
| Toyota | Tercel | Small | 7.8 | 9.8 | 11.8 | 32 | 37 | Driver only | Front | 4 | 1.5 | 82 | 5200 | 3505 | Yes | 11.9 | 5 | 162 | 94 | 65 | 36 | 24 | 11 | 2055 | non-USA | Toyota Tercel |
| Toyota | Celica | Sporty | 14.2 | 18.4 | 22.6 | 25 | 32 | Driver only | Front | 4 | 2.2 | 135 | 5400 | 2405 | Yes | 15.9 | 4 | 174 | 99 | 69 | 39 | 23 | 13 | 2950 | non-USA | Toyota Celica |
| Toyota | Camry | Midsize | 15.2 | 18.2 | 21.2 | 22 | 29 | Driver only | Front | 4 | 2.2 | 130 | 5400 | 2340 | Yes | 18.5 | 5 | 188 | 103 | 70 | 38 | 28.5 | 15 | 3030 | non-USA | Toyota Camry |
| Toyota | Previa | Van | 18.9 | 22.7 | 26.6 | 18 | 22 | Driver only | 4WD | 4 | 2.4 | 138 | 5000 | 2515 | Yes | 19.8 | 7 | 187 | 113 | 71 | 41 | 35 | 3785 | non-USA | Toyota Previa | |
| Volkswagen | Fox | Small | 8.7 | 9.1 | 9.5 | 25 | 33 | None | Front | 4 | 1.8 | 81 | 5500 | 2550 | Yes | 12.4 | 4 | 163 | 93 | 63 | 34 | 26 | 10 | 2240 | non-USA | Volkswagen Fox |
| Volkswagen | Eurovan | Van | 16.6 | 19.7 | 22.7 | 17 | 21 | None | Front | 5 | 2.5 | 109 | 4500 | 2915 | Yes | 21.1 | 7 | 187 | 115 | 72 | 38 | 34 | 3960 | non-USA | Volkswagen Eurovan | |
| Volkswagen | Passat | Compact | 17.6 | 20 | 22.4 | 21 | 30 | None | Front | 4 | 2 | 134 | 5800 | 2685 | Yes | 18.5 | 5 | 180 | 103 | 67 | 35 | 31.5 | 14 | 2985 | non-USA | Volkswagen Passat |
| Volkswagen | Corrado | Sporty | 22.9 | 23.3 | 23.7 | 18 | 25 | None | Front | 6 | 2.8 | 178 | 5800 | 2385 | Yes | 18.5 | 4 | 159 | 97 | 66 | 36 | 26 | 15 | 2810 | non-USA | Volkswagen Corrado |
| Volvo | 240 | Compact | 21.8 | 22.7 | 23.5 | 21 | 28 | Driver only | Rear | 4 | 2.3 | 114 | 5400 | 2215 | Yes | 15.8 | 5 | 190 | 104 | 67 | 37 | 29.5 | 14 | 2985 | non-USA | Volvo 240 |
| Volvo | 850 | Midsize | 24.8 | 26.7 | 28.5 | 20 | 28 | Driver & Passenger | Front | 5 | 2.4 | 168 | 6200 | 2310 | Yes | 19.3 | 5 | 184 | 105 | 69 | 38 | 30 | 15 | 3245 | non-USA | Volvo 850 |
(def cars93-correlations
"Correlation of every pair of numeric Cars93 columns, over the rows where both are present."
(let [columns [:min-price :price :max-price :mpg-city :mpg-highway :engine-size :horsepower :rpm :rev-per-mile
:fuel-tank-capacity :passengers :length :wheelbase :width :turn-circle :rear-seat-room
:luggage-room :weight]]
(vec (for [a columns, b columns
:let [pairs (filter #(and (some? (a %)) (some? (b %))) cars93)]]
{:row (name a) :column (name b) :r (stats/correlation (map a pairs) (map b pairs))}))))| row | column | r |
|---|---|---|
| min-price | min-price | 1.0 |
| min-price | price | 0.9706014017830377 |
| min-price | max-price | 0.906756076744809 |
| min-price | mpg-city | -0.6228754378819865 |
| min-price | mpg-highway | -0.5799658128357866 |
| min-price | engine-size | 0.6454876677956223 |
| min-price | horsepower | 0.8024441158160064 |
| min-price | rpm | -0.042598158242726926 |
| min-price | rev-per-mile | -0.4703949892221343 |
| min-price | fuel-tank-capacity | 0.6353690222437547 |
| min-price | passengers | 0.061236437997991916 |
| min-price | length | 0.5538588079605768 |
| min-price | wheelbase | 0.5167578572112066 |
| min-price | width | 0.492878300930305 |
| min-price | turn-circle | 0.42860290424013775 |
| min-price | rear-seat-room | 0.37664209868689 |
| min-price | luggage-room | 0.41348464690824255 |
| min-price | weight | 0.6665537674004086 |
| price | min-price | 0.9706014017830377 |
| price | price | 1.0 |
| price | max-price | 0.9815802720120923 |
| price | mpg-city | -0.594562163314947 |
| price | mpg-highway | -0.5606803617055318 |
| price | engine-size | 0.5974253916659135 |
| price | horsepower | 0.7882175778513335 |
| price | rpm | -0.004954931392456918 |
| price | rev-per-mile | -0.4263951130311043 |
| price | fuel-tank-capacity | 0.619479980745119 |
| price | passengers | 0.057860073691324454 |
| price | length | 0.5036284404653106 |
| price | wheelbase | 0.5008641627249432 |
| price | width | 0.4560278659301728 |
| price | turn-circle | 0.3925899267214403 |
| price | rear-seat-room | 0.31149881902025456 |
| price | luggage-room | 0.3665685586705611 |
| price | weight | 0.6471790053743406 |
| max-price | min-price | 0.906756076744809 |
| max-price | price | 0.9815802720120923 |
| max-price | max-price | 1.0 |
| max-price | mpg-city | -0.5478109021982839 |
| max-price | mpg-highway | -0.5225607445585139 |
| max-price | engine-size | 0.5350119673948089 |
| max-price | horsepower | 0.744444745784467 |
| max-price | rpm | 0.025014781800050383 |
| max-price | rev-per-mile | -0.3740242136529774 |
| max-price | fuel-tank-capacity | 0.5812943884021613 |
| max-price | passengers | 0.05321591694886588 |
| max-price | length | 0.44293341142824777 |
| max-price | wheelbase | 0.46750078758586855 |
| max-price | width | 0.40841435111615604 |
| max-price | turn-circle | 0.3477848545969153 |
| max-price | rear-seat-room | 0.24725978768062745 |
| max-price | luggage-room | 0.31531537566645745 |
| max-price | weight | 0.605141566330808 |
| mpg-city | min-price | -0.6228754378819865 |
| mpg-city | price | -0.594562163314947 |
| mpg-city | max-price | -0.5478109021982839 |
| mpg-city | mpg-city | 1.0 |
| mpg-city | mpg-highway | 0.9439357893445909 |
| mpg-city | engine-size | -0.7100031616203692 |
| mpg-city | horsepower | -0.6726361507957244 |
| mpg-city | rpm | 0.36304512864824146 |
| mpg-city | rev-per-mile | 0.69585698569207 |
| mpg-city | fuel-tank-capacity | -0.8131444169922427 |
| mpg-city | passengers | -0.41685585933414004 |
| mpg-city | length | -0.6662390348989818 |
| mpg-city | wheelbase | -0.6671076476226464 |
| mpg-city | width | -0.7205344021381329 |
| mpg-city | turn-circle | -0.6663888975315526 |
| mpg-city | rear-seat-room | -0.38434686421751213 |
| mpg-city | luggage-room | -0.4948936449702689 |
| mpg-city | weight | -0.84313854799682 |
| mpg-highway | min-price | -0.5799658128357866 |
| mpg-highway | price | -0.5606803617055318 |
| mpg-highway | max-price | -0.5225607445585139 |
| mpg-highway | mpg-city | 0.9439357893445909 |
| mpg-highway | mpg-highway | 1.0 |
| mpg-highway | engine-size | -0.6267945530726069 |
| mpg-highway | horsepower | -0.6190436848094556 |
| mpg-highway | rpm | 0.31346872793461716 |
| mpg-highway | rev-per-mile | 0.5874967908701213 |
| mpg-highway | fuel-tank-capacity | -0.7860386347943433 |
| mpg-highway | passengers | -0.46638582667436046 |
| mpg-highway | length | -0.5428974108177609 |
| mpg-highway | wheelbase | -0.615384249777684 |
| mpg-highway | width | -0.6403592165584162 |
| mpg-highway | turn-circle | -0.5936832790109131 |
| mpg-highway | rear-seat-room | -0.3666843815333906 |
| mpg-highway | luggage-room | -0.3716290913791111 |
| mpg-highway | weight | -0.8106580570674169 |
| engine-size | min-price | 0.6454876677956223 |
| engine-size | price | 0.5974253916659135 |
| engine-size | max-price | 0.5350119673948089 |
| engine-size | mpg-city | -0.7100031616203692 |
| engine-size | mpg-highway | -0.6267945530726069 |
| engine-size | engine-size | 1.0 |
| engine-size | horsepower | 0.7321197304173866 |
| engine-size | rpm | -0.5478978052071475 |
| engine-size | rev-per-mile | -0.8240086056811998 |
| engine-size | fuel-tank-capacity | 0.7593062249034012 |
| … | … | … |
(plot/render-image
{:data cars93-correlations
:mapping {:x :row :y :column :color :r}
:scales {:color {:domain [-1 1] :range :spectral-11}}
:charts [(chart/tile)]
:theme {:axis {:x {:label-rotation -90}}}
:labels {:x nil :y nil}}
{:width 900 :height 800})
38.6.12 Fig 6.13 Ordered by clustering
The same matrix, rows and columns in the order of a hierarchical clustering (the clustered heatmap without its dendrograms).
Source: Lattice Fig 6.13. Data: Cars on sale in the USA, 1993, R MASS package Cars93 (Lock 1993); licence: GPL-2 | GPL-3 (MASS).
(plot/render-image
(plot/clustered-heatmap cars93-correlations {:row :row :col :column :value :r :row-tree? false :col-tree? false
:scales {:color {:domain [-1 1] :range :spectral-11}}})
{:width 900 :height 800})
38.6.13 Fig 6.14 Cell sizes
Chem97 counts of A-level score by GCSE score decile per gender: colour and size by the square root of the count, the colour bar labelled in counts.
Source: Lattice Fig 6.14. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(def chem97-deciles
"Chem97 counts by A-level score, GCSE score decile and gender, every combination (zeros included)."
(let [binned (levels/bin chem97 :gcsescore {:as :gcd :bins {:quantiles 10}})
counts (frequencies (map (juxt :score :gcd :gender) binned))]
(vec (for [gender ["M" "F"], score (sort (distinct (map :score binned))), gcd (sort (distinct (map :gcd binned)))]
{:score score :gcd gcd :gender gender :count (get counts [score gcd gender] 0)}))))| score | gcd | gender | count |
|---|---|---|---|
| 0 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | M | 962 |
| 0 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | M | 567 |
| 0 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | M | 268 |
| 0 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | M | 183 |
| 0 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | M | 125 |
| 0 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | M | 52 |
| 0 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | M | 24 |
| 0 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | M | 8 |
| 0 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | M | 7 |
| 0 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | M | 2 |
| 2 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | M | 509 |
| 2 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | M | 481 |
| 2 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | M | 315 |
| 2 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | M | 320 |
| 2 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | M | 186 |
| 2 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | M | 115 |
| 2 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | M | 53 |
| 2 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | M | 23 |
| 2 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | M | 24 |
| 2 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | M | 1 |
| 4 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | M | 403 |
| 4 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | M | 465 |
| 4 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | M | 395 |
| 4 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | M | 447 |
| 4 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | M | 296 |
| 4 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | M | 254 |
| 4 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | M | 156 |
| 4 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | M | 61 |
| 4 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | M | 70 |
| 4 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | M | 8 |
| 6 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | M | 243 |
| 6 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | M | 368 |
| 6 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | M | 381 |
| 6 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | M | 492 |
| 6 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | M | 491 |
| 6 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | M | 418 |
| 6 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | M | 303 |
| 6 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | M | 160 |
| 6 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | M | 207 |
| 6 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | M | 40 |
| 8 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | M | 105 |
| 8 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | M | 202 |
| 8 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | M | 245 |
| 8 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | M | 398 |
| 8 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | M | 456 |
| 8 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | M | 501 |
| 8 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | M | 523 |
| 8 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | M | 354 |
| 8 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | M | 652 |
| 8 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | M | 198 |
| 10 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | M | 21 |
| 10 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | M | 30 |
| 10 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | M | 71 |
| 10 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | M | 139 |
| 10 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | M | 190 |
| 10 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | M | 283 |
| 10 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | M | 422 |
| 10 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | M | 353 |
| 10 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | M | 1126 |
| 10 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | M | 1110 |
| 0 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | F | 398 |
| 0 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | F | 329 |
| 0 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | F | 225 |
| 0 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | F | 202 |
| 0 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | F | 151 |
| 0 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | F | 97 |
| 0 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | F | 49 |
| 0 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | F | 13 |
| 0 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | F | 22 |
| 0 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | F | 4 |
| 2 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | F | 181 |
| 2 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | F | 283 |
| 2 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | F | 241 |
| 2 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | F | 298 |
| 2 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | F | 221 |
| 2 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | F | 156 |
| 2 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | F | 124 |
| 2 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | F | 37 |
| 2 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | F | 54 |
| 2 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | F | 5 |
| 4 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | F | 103 |
| 4 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | F | 211 |
| 4 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | F | 231 |
| 4 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | F | 380 |
| 4 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | F | 333 |
| 4 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | F | 281 |
| 4 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | F | 238 |
| 4 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | F | 107 |
| 4 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | F | 150 |
| 4 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | F | 30 |
| 6 | #cljplot2.data.shingle.Interval{:lo 0.0, :hi 5.125, :label nil, :closed :left, :digits 3} | F | 62 |
| 6 | #cljplot2.data.shingle.Interval{:lo 5.125, :hi 5.571, :label nil, :closed :left, :digits 3} | F | 147 |
| 6 | #cljplot2.data.shingle.Interval{:lo 5.571, :hi 5.875, :label nil, :closed :left, :digits 3} | F | 177 |
| 6 | #cljplot2.data.shingle.Interval{:lo 5.875, :hi 6.125, :label nil, :closed :left, :digits 3} | F | 329 |
| 6 | #cljplot2.data.shingle.Interval{:lo 6.125, :hi 6.375, :label nil, :closed :left, :digits 3} | F | 411 |
| 6 | #cljplot2.data.shingle.Interval{:lo 6.375, :hi 6.6, :label nil, :closed :left, :digits 3} | F | 438 |
| 6 | #cljplot2.data.shingle.Interval{:lo 6.6, :hi 6.8, :label nil, :closed :left, :digits 3} | F | 410 |
| 6 | #cljplot2.data.shingle.Interval{:lo 6.8, :hi 7.0, :label nil, :closed :left, :digits 3} | F | 191 |
| 6 | #cljplot2.data.shingle.Interval{:lo 7.0, :hi 7.375, :label nil, :closed :left, :digits 3} | F | 382 |
| 6 | #cljplot2.data.shingle.Interval{:lo 7.375, :hi 8.0, :label nil, :closed nil, :digits 3} | F | 89 |
| … | … | … | … |
(plot/render-image
{:data (map #(assoc % :root (m/sqrt (:count %))) chem97-deciles)
:mapping {:x (levels/categorical :score) :y :gcd :color :root :size :root :facet :gender}
:scales {:size {:range [7 10] :legend false}
:facet {:domain ["M" "F"]}
:color {:formatter #(str (m/round (* (double %) (double %)))) :title "count"}}
:charts [(chart/tile)]
:facets {:columns 2}
:labels {:x "score" :y "gcd"}}
{:width 900 :height 500})
38.6.14 Fig 6.15 Bars in three dimensions
Source: Lattice Fig 6.15. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97-deciles
:mapping {:x (levels/categorical :score) :y :gcd :z :count :facet :gender}
:scales {:facet {:domain ["M" "F"]}}
:charts [(chart/cloud {:type :bars :base 0 :color [180 180 180] :stroke-color [60 60 60] :stroke-width 1
:view {:azimuth 40 :elevation 65 :distance 0.2} :aspect [1 1.5 0.75] :axis-titles {:x "score" :y "gcd" :z "Freq"}})]
:facets {:columns 2}}
{:width 1000 :height 550})
Not reproduced: Figs 6.16 and 6.17 (copula densities - not in fastmath).
38.6.15 Fig 6.18 A parametric surface
A twisted band: x, y, z functions of angles u and v (the book’s kx, ky, kz with r = 2, t = 1), shaded, translucent. Seen from the side opposite the book’s view (its z = 170, azimuth -170), so x and y grow left to right without mirroring the band (:reverse #{:x} at the book’s view would mirror it).
Source: Lattice Fig 6.18.
(plot/render-image
{:charts [(chart/surface {:fu (fn [[u v]]
(let [band (+ 2.0 (* (m/cos (/ u 2.0)) (m/sin v)) (- (* (m/sin (/ u 2.0)) (m/sin (* 2.0 v)))))]
[(* (m/cos u) band) (* (m/sin u) band)
(+ (* (m/sin (/ u 2.0)) (m/sin v)) (* (m/cos (/ u 2.0)) (m/sin v)))]))
:u [(* 0.3 m/TWO_PI) (* 1.25 m/TWO_PI)] :v [0.0 m/TWO_PI] :n 50
:aspect [1 1 0.4] :view {:azimuth 10 :elevation 30 :distance 0.2}
:axis-titles {:x "kx(um, vm)" :y "ky(um, vm)" :z "kz(um, vm)"}})]
:scales {:color {:range [[60 80 200 190] [80 200 200 190] [240 230 120 190] [220 80 160 190]]}}}
{:width 800 :height 600})
38.6.16 Fig 6.19 A level plot of population
US population by age and year, 1900 - 1979, per sex, on a spectral palette.
Source: Lattice Fig 6.19. Data: US population by age and sex, 1900-1979, R latticeExtra package USAge.df (US Census Bureau); licence: GPL (>= 2) (latticeExtra).
(plot/render-image
{:data (nu/dataset :us-age)
:mapping {:x :year :y :age :color :population :facet :sex}
:scales {:color {:range :spectral-11} :facet {:domain (nu/levels :us-age :sex)}}
:charts [(chart/tile)]
:facets {:columns 2}
:aspect :iso
:labels {:x "Year" :y "Age"}}
{:width 900 :height 500})
38.7 Chapter 7 - Graphical Parameters and Other Settings
38.7.1 Fig 7.1 Ordered groups with stems
Virginia death rates, a panel per age group; the population groups ordered by their mean rate.
Source: Lattice Fig 7.1. Data: Death rates in Virginia (1940), R datasets package VADeaths (Molyneaux et al. 1947); licence: Part of R (GPL-2 | GPL-3).
(def va-plot
{:data va-deaths
:mapping {:x :rate :y :group :facet :age}
:scales {:y {:order-by #(stats/mean (map :rate %))}}
:facets {:columns 5}
:labels {:title "Death Rates in Virginia - 1940" :x "Number of deaths per 100" :y nil}})(plot/render-image
(assoc va-plot :charts [(chart/segment {:xend 0}) (chart/scatter)])
{:width 1000 :height 350})
38.7.2 Fig 7.2 Changed settings
The book changes lattice’s settings: no dotted guide lines, stems twice as wide. Here the same as plot options - no grid, :width 2.
Source: Lattice Fig 7.2. Data: Death rates in Virginia (1940), R datasets package VADeaths (Molyneaux et al. 1947); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
(assoc va-plot
:charts [(chart/segment {:xend 0 :width 2}) (chart/scatter)]
:theme {:panel {:grid {:x :none :y :none}}})
{:width 1000 :height 350})
38.7.3 Fig 7.3 Settings and their parameters
Which graphical parameters (columns) each lattice setting (rows) has: parameters by how many settings use them, settings by how many parameters they have.
Source: Lattice Fig 7.3. Data: lattice graphical settings and their parameters, R lattice package trellis.par.get() (Sarkar 2008, Fig 7.3); licence: GPL (>= 2) (lattice).
| setting | parameter |
|---|---|
| background | alpha |
| background | col |
| panel.background | col |
| add.line | alpha |
| add.line | col |
| add.line | lty |
| add.line | lwd |
| add.text | alpha |
| add.text | cex |
| add.text | col |
| add.text | font |
| add.text | lineheight |
| plot.polygon | alpha |
| plot.polygon | col |
| plot.polygon | border |
| plot.polygon | lty |
| plot.polygon | lwd |
| box.dot | alpha |
| box.dot | col |
| box.dot | cex |
| box.dot | font |
| box.dot | pch |
| box.rectangle | alpha |
| box.rectangle | col |
| box.rectangle | fill |
| box.rectangle | lty |
| box.rectangle | lwd |
| box.umbrella | alpha |
| box.umbrella | col |
| box.umbrella | lty |
| box.umbrella | lwd |
| dot.line | alpha |
| dot.line | col |
| dot.line | lty |
| dot.line | lwd |
| dot.symbol | alpha |
| dot.symbol | cex |
| dot.symbol | col |
| dot.symbol | font |
| dot.symbol | pch |
| plot.line | alpha |
| plot.line | col |
| plot.line | lty |
| plot.line | lwd |
| plot.symbol | alpha |
| plot.symbol | cex |
| plot.symbol | col |
| plot.symbol | font |
| plot.symbol | pch |
| plot.symbol | fill |
| reference.line | alpha |
| reference.line | col |
| reference.line | lty |
| reference.line | lwd |
| strip.background | alpha |
| strip.background | col |
| strip.shingle | alpha |
| strip.shingle | col |
| strip.border | alpha |
| strip.border | col |
| strip.border | lty |
| strip.border | lwd |
| superpose.line | alpha |
| superpose.line | col |
| superpose.line | lty |
| superpose.line | lwd |
| superpose.symbol | alpha |
| superpose.symbol | cex |
| superpose.symbol | col |
| superpose.symbol | fill |
| superpose.symbol | font |
| superpose.symbol | pch |
| superpose.polygon | alpha |
| superpose.polygon | col |
| superpose.polygon | border |
| superpose.polygon | lty |
| superpose.polygon | lwd |
| regions | alpha |
| regions | col |
| shade.colors | alpha |
| shade.colors | palette |
| axis.line | alpha |
| axis.line | col |
| axis.line | lty |
| axis.line | lwd |
| axis.text | alpha |
| axis.text | cex |
| axis.text | col |
| axis.text | font |
| axis.text | lineheight |
| box.3d | alpha |
| box.3d | col |
| box.3d | lty |
| box.3d | lwd |
| par.title.text | alpha |
| par.title.text | cex |
| par.title.text | col |
| par.title.text | font |
| par.title.text | lineheight |
| par.xlab.text | alpha |
| … | … |
(let [settings (nu/dataset :lattice-settings)
by-count (fn [k descending?] (->> (frequencies (map k settings)) (sort-by (fn [[v n]] [(if descending? (- n) n) v])) (mapv key)))]
(plot/render-image
{:data settings
:mapping {:x :parameter :y :setting}
:scales {:x {:domain (by-count :parameter true)} :y {:domain (by-count :setting false)}}
:charts [(chart/scatter {:size 5 :color :black})]
:theme {:panel {:grid {:x {:color [160 160 160] :width 0.5 :dash :none} :y {:color [160 160 160] :width 0.5 :dash :none}}}}
:labels {:x "Graphical parameters" :y "Setting names"}}
{:width 900 :height 700}))
Not reproduced: Fig 7.4 (lattice’s own graphical settings).
38.8 Chapter 8 - Plot Coordinates and Axis Annotation
38.8.1 Fig 8.1 A reversed axis
Depth growing downward (a reversed y domain), jittered by magnitude.
Source: Lattice Fig 8.1. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data quakes
:mapping {:x (levels/categorical :mag) :y :depth}
:scales {:y {:domain [700 0]}}
:charts [(chart/stripplot {:rng (r/rng :mersenne 81)})]
:labels {:x "Magnitude (Richter scale)" :y "depth"}}
{:width 900 :height 400})
38.8.2 Fig 8.2 A long series cut into slices
Hourly accesses of the Bioconductor website in 2007, cut into nine overlapping time slices (a shingle of the hours: equal counts of hourly rows, so equal lengths), each panel its own date range, no strips. Lattice’s relation = "sliced" (equal ranges) needs numbers in cljplot2; the equal-length slices make :free the same.
Source: Lattice Fig 8.2. Data: Hourly accesses of the Bioconductor website, 2007, R latticeExtra package biocAccess (Bioconductor web logs); licence: GPL (>= 2) (latticeExtra).
| counts | day | month | year | hour | weekday | time |
|---|---|---|---|---|---|---|
| 390 | 1 | Jan | 2007 | 0 | Monday | 2007-01-01T00:00:00 |
| 768 | 1 | Jan | 2007 | 1 | Monday | 2007-01-01T01:00:00 |
| 528 | 1 | Jan | 2007 | 2 | Monday | 2007-01-01T02:00:00 |
| 547 | 1 | Jan | 2007 | 3 | Monday | 2007-01-01T03:00:00 |
| 545 | 1 | Jan | 2007 | 4 | Monday | 2007-01-01T04:00:00 |
| 460 | 1 | Jan | 2007 | 5 | Monday | 2007-01-01T05:00:00 |
| 1034 | 1 | Jan | 2007 | 6 | Monday | 2007-01-01T06:00:00 |
| 1004 | 1 | Jan | 2007 | 7 | Monday | 2007-01-01T07:00:00 |
| 1263 | 1 | Jan | 2007 | 8 | Monday | 2007-01-01T08:00:00 |
| 1158 | 1 | Jan | 2007 | 9 | Monday | 2007-01-01T09:00:00 |
| 1586 | 1 | Jan | 2007 | 10 | Monday | 2007-01-01T10:00:00 |
| 1576 | 1 | Jan | 2007 | 11 | Monday | 2007-01-01T11:00:00 |
| 1645 | 1 | Jan | 2007 | 12 | Monday | 2007-01-01T12:00:00 |
| 892 | 1 | Jan | 2007 | 13 | Monday | 2007-01-01T13:00:00 |
| 1275 | 1 | Jan | 2007 | 14 | Monday | 2007-01-01T14:00:00 |
| 1248 | 1 | Jan | 2007 | 15 | Monday | 2007-01-01T15:00:00 |
| 867 | 1 | Jan | 2007 | 16 | Monday | 2007-01-01T16:00:00 |
| 891 | 1 | Jan | 2007 | 17 | Monday | 2007-01-01T17:00:00 |
| 1019 | 1 | Jan | 2007 | 18 | Monday | 2007-01-01T18:00:00 |
| 5927 | 1 | Jan | 2007 | 19 | Monday | 2007-01-01T19:00:00 |
| 7431 | 1 | Jan | 2007 | 20 | Monday | 2007-01-01T20:00:00 |
| 7171 | 1 | Jan | 2007 | 21 | Monday | 2007-01-01T21:00:00 |
| 9113 | 1 | Jan | 2007 | 22 | Monday | 2007-01-01T22:00:00 |
| 1415 | 1 | Jan | 2007 | 23 | Monday | 2007-01-01T23:00:00 |
| 938 | 2 | Jan | 2007 | 0 | Tuesday | 2007-01-02T00:00:00 |
| 1513 | 2 | Jan | 2007 | 1 | Tuesday | 2007-01-02T01:00:00 |
| 1217 | 2 | Jan | 2007 | 2 | Tuesday | 2007-01-02T02:00:00 |
| 1539 | 2 | Jan | 2007 | 3 | Tuesday | 2007-01-02T03:00:00 |
| 1196 | 2 | Jan | 2007 | 4 | Tuesday | 2007-01-02T04:00:00 |
| 2145 | 2 | Jan | 2007 | 5 | Tuesday | 2007-01-02T05:00:00 |
| 1805 | 2 | Jan | 2007 | 6 | Tuesday | 2007-01-02T06:00:00 |
| 2225 | 2 | Jan | 2007 | 7 | Tuesday | 2007-01-02T07:00:00 |
| 1830 | 2 | Jan | 2007 | 8 | Tuesday | 2007-01-02T08:00:00 |
| 2099 | 2 | Jan | 2007 | 9 | Tuesday | 2007-01-02T09:00:00 |
| 1753 | 2 | Jan | 2007 | 10 | Tuesday | 2007-01-02T10:00:00 |
| 2440 | 2 | Jan | 2007 | 11 | Tuesday | 2007-01-02T11:00:00 |
| 1624 | 2 | Jan | 2007 | 12 | Tuesday | 2007-01-02T12:00:00 |
| 1610 | 2 | Jan | 2007 | 13 | Tuesday | 2007-01-02T13:00:00 |
| 1164 | 2 | Jan | 2007 | 14 | Tuesday | 2007-01-02T14:00:00 |
| 1579 | 2 | Jan | 2007 | 15 | Tuesday | 2007-01-02T15:00:00 |
| 1498 | 2 | Jan | 2007 | 16 | Tuesday | 2007-01-02T16:00:00 |
| 1081 | 2 | Jan | 2007 | 17 | Tuesday | 2007-01-02T17:00:00 |
| 2420 | 2 | Jan | 2007 | 18 | Tuesday | 2007-01-02T18:00:00 |
| 2628 | 2 | Jan | 2007 | 19 | Tuesday | 2007-01-02T19:00:00 |
| 2061 | 2 | Jan | 2007 | 20 | Tuesday | 2007-01-02T20:00:00 |
| 1457 | 2 | Jan | 2007 | 21 | Tuesday | 2007-01-02T21:00:00 |
| 1182 | 2 | Jan | 2007 | 22 | Tuesday | 2007-01-02T22:00:00 |
| 3169 | 2 | Jan | 2007 | 23 | Tuesday | 2007-01-02T23:00:00 |
| 3351 | 3 | Jan | 2007 | 0 | Wednesday | 2007-01-03T00:00:00 |
| 5469 | 3 | Jan | 2007 | 1 | Wednesday | 2007-01-03T01:00:00 |
| 5451 | 3 | Jan | 2007 | 2 | Wednesday | 2007-01-03T02:00:00 |
| 2406 | 3 | Jan | 2007 | 3 | Wednesday | 2007-01-03T03:00:00 |
| 1587 | 3 | Jan | 2007 | 4 | Wednesday | 2007-01-03T04:00:00 |
| 5595 | 3 | Jan | 2007 | 5 | Wednesday | 2007-01-03T05:00:00 |
| 2914 | 3 | Jan | 2007 | 6 | Wednesday | 2007-01-03T06:00:00 |
| 2509 | 3 | Jan | 2007 | 7 | Wednesday | 2007-01-03T07:00:00 |
| 3103 | 3 | Jan | 2007 | 8 | Wednesday | 2007-01-03T08:00:00 |
| 2750 | 3 | Jan | 2007 | 9 | Wednesday | 2007-01-03T09:00:00 |
| 1885 | 3 | Jan | 2007 | 10 | Wednesday | 2007-01-03T10:00:00 |
| 2603 | 3 | Jan | 2007 | 11 | Wednesday | 2007-01-03T11:00:00 |
| 2730 | 3 | Jan | 2007 | 12 | Wednesday | 2007-01-03T12:00:00 |
| 2091 | 3 | Jan | 2007 | 13 | Wednesday | 2007-01-03T13:00:00 |
| 1923 | 3 | Jan | 2007 | 14 | Wednesday | 2007-01-03T14:00:00 |
| 1331 | 3 | Jan | 2007 | 15 | Wednesday | 2007-01-03T15:00:00 |
| 1352 | 3 | Jan | 2007 | 16 | Wednesday | 2007-01-03T16:00:00 |
| 864 | 3 | Jan | 2007 | 17 | Wednesday | 2007-01-03T17:00:00 |
| 1614 | 3 | Jan | 2007 | 18 | Wednesday | 2007-01-03T18:00:00 |
| 8364 | 3 | Jan | 2007 | 19 | Wednesday | 2007-01-03T19:00:00 |
| 8105 | 3 | Jan | 2007 | 20 | Wednesday | 2007-01-03T20:00:00 |
| 7576 | 3 | Jan | 2007 | 21 | Wednesday | 2007-01-03T21:00:00 |
| 7808 | 3 | Jan | 2007 | 22 | Wednesday | 2007-01-03T22:00:00 |
| 1923 | 3 | Jan | 2007 | 23 | Wednesday | 2007-01-03T23:00:00 |
| 1363 | 4 | Jan | 2007 | 0 | Thursday | 2007-01-04T00:00:00 |
| 2901 | 4 | Jan | 2007 | 1 | Thursday | 2007-01-04T01:00:00 |
| 1740 | 4 | Jan | 2007 | 2 | Thursday | 2007-01-04T02:00:00 |
| 1823 | 4 | Jan | 2007 | 3 | Thursday | 2007-01-04T03:00:00 |
| 2542 | 4 | Jan | 2007 | 4 | Thursday | 2007-01-04T04:00:00 |
| 2683 | 4 | Jan | 2007 | 5 | Thursday | 2007-01-04T05:00:00 |
| 2449 | 4 | Jan | 2007 | 6 | Thursday | 2007-01-04T06:00:00 |
| 3346 | 4 | Jan | 2007 | 7 | Thursday | 2007-01-04T07:00:00 |
| 2266 | 4 | Jan | 2007 | 8 | Thursday | 2007-01-04T08:00:00 |
| 3344 | 4 | Jan | 2007 | 9 | Thursday | 2007-01-04T09:00:00 |
| 1656 | 4 | Jan | 2007 | 10 | Thursday | 2007-01-04T10:00:00 |
| 2123 | 4 | Jan | 2007 | 11 | Thursday | 2007-01-04T11:00:00 |
| 2167 | 4 | Jan | 2007 | 12 | Thursday | 2007-01-04T12:00:00 |
| 1939 | 4 | Jan | 2007 | 13 | Thursday | 2007-01-04T13:00:00 |
| 2082 | 4 | Jan | 2007 | 14 | Thursday | 2007-01-04T14:00:00 |
| 1382 | 4 | Jan | 2007 | 15 | Thursday | 2007-01-04T15:00:00 |
| 1178 | 4 | Jan | 2007 | 16 | Thursday | 2007-01-04T16:00:00 |
| 3537 | 4 | Jan | 2007 | 17 | Thursday | 2007-01-04T17:00:00 |
| 1877 | 4 | Jan | 2007 | 18 | Thursday | 2007-01-04T18:00:00 |
| 6341 | 4 | Jan | 2007 | 19 | Thursday | 2007-01-04T19:00:00 |
| 8413 | 4 | Jan | 2007 | 20 | Thursday | 2007-01-04T20:00:00 |
| 7691 | 4 | Jan | 2007 | 21 | Thursday | 2007-01-04T21:00:00 |
| 8280 | 4 | Jan | 2007 | 22 | Thursday | 2007-01-04T22:00:00 |
| 7384 | 4 | Jan | 2007 | 23 | Thursday | 2007-01-04T23:00:00 |
| 1469 | 5 | Jan | 2007 | 0 | Friday | 2007-01-05T00:00:00 |
| 1470 | 5 | Jan | 2007 | 1 | Friday | 2007-01-05T01:00:00 |
| 2209 | 5 | Jan | 2007 | 2 | Friday | 2007-01-05T02:00:00 |
| 1995 | 5 | Jan | 2007 | 3 | Friday | 2007-01-05T03:00:00 |
| … | … | … | … | … | … | … |
(plot/render-image
{:data (shingle/shingle (map-indexed (fn [i row] (assoc row :hour-index i :thousands (/ (:counts row) 1000.0)
:date (java.time.LocalDateTime/parse (:time row))))
(nu/dataset :bioc-access))
:hour-index {:count 9 :overlap 0.1 :as :slice})
:mapping {:x :date :y :thousands :facet :slice}
:scales {:x {:nice false :formatter "MMM dd"}}
:charts [(chart/line {:width 0.6 :padding {:x [0 0] :y [0.05 0.05]}})]
:facets {:columns 1 :strips false :scales {:x :free}}
:labels {:x nil :y "Number of accesses (thousands)"}}
{:width 900 :height 800})
38.8.3 Fig 8.3 Logarithmic axes, banked
Source: Lattice Fig 8.3. Data: Western US earthquakes: ground acceleration, R MEMSS package Earthquake (Joyner & Boore 1981); licence: GPL (>= 2) (MEMSS).
(plot/render-image
{:data earthquake
:mapping {:x :distance :y :accel}
:scales log2-axes
:charts [(chart/scatter) (chart/smooth {:band :none})]
:labels earthquake-labels}
{:width 500 :height 550})
38.8.4 Fig 8.4 Chosen tick positions
Log-2 axes: distances labelled at 1, 3, 10, 30, … (explicit ticks), accelerations as powers of two; a panel per magnitude class. (The book also labels the right axis with fractions - no secondary axes here.)
Source: Lattice Fig 8.4. Data: Western US earthquakes: ground acceleration, R MEMSS package Earthquake (Joyner & Boore 1981); licence: GPL (>= 2) (MEMSS).
(plot/render-image
{:data (levels/bin earthquake :richter {:as :magnitude :bins [4.9 5.5 6.5 7.8]})
:mapping {:x :distance :y :accel :facet :magnitude}
:scales {:x {:kind :log :base 2 :ticks [1 3 10 30 100 300]} :y {:kind :log :base 2 :formatter :power}}
:charts [(chart/scatter)]
:facets {:columns 3}
:labels earthquake-labels}
{:width 900 :height 400})
38.8.5 Fig 8.5 Minor ticks
Log-10 axes with minor ticks at 2 … 9 of every decade.
Source: Lattice Fig 8.5. Data: Western US earthquakes: ground acceleration, R MEMSS package Earthquake (Joyner & Boore 1981); licence: GPL (>= 2) (MEMSS).
(plot/render-image
{:data earthquake
:mapping {:x :distance :y :accel}
:scales {:x {:kind :log :minor-ticks 1} :y {:kind :log}}
:charts [(chart/scatter)]
:theme {:panel {:grid {:minor {:color [180 180 180] :width 0.5 :dash [1.0 2.0]}}}}
:labels earthquake-labels}
{:width 500 :height 550})
38.8.6 Fig 8.6 Fahrenheit and Celsius
Yearly mean temperature in New Haven. The book adds a Celsius axis on the right; here the two scales are two plots (no secondary axes).
Source: Lattice Fig 8.6. Data: Mean annual temperature, New Haven 1912-1971, R datasets package nhtemp (Vaux 1972); licence: Part of R (GPL-2 | GPL-3).
| time | value |
|---|---|
| 1912 | 49.9 |
| 1913 | 52.3 |
| 1914 | 49.4 |
| 1915 | 51.1 |
| 1916 | 49.4 |
| 1917 | 47.9 |
| 1918 | 49.8 |
| 1919 | 50.9 |
| 1920 | 49.3 |
| 1921 | 51.9 |
| 1922 | 50.8 |
| 1923 | 49.6 |
| 1924 | 49.3 |
| 1925 | 50.6 |
| 1926 | 48.4 |
| 1927 | 50.7 |
| 1928 | 50.9 |
| 1929 | 50.6 |
| 1930 | 51.5 |
| 1931 | 52.8 |
| 1932 | 51.8 |
| 1933 | 51.1 |
| 1934 | 49.8 |
| 1935 | 50.2 |
| 1936 | 50.4 |
| 1937 | 51.6 |
| 1938 | 51.8 |
| 1939 | 50.9 |
| 1940 | 48.8 |
| 1941 | 51.7 |
| 1942 | 51 |
| 1943 | 50.6 |
| 1944 | 51.7 |
| 1945 | 51.5 |
| 1946 | 52.1 |
| 1947 | 51.3 |
| 1948 | 51 |
| 1949 | 54 |
| 1950 | 51.4 |
| 1951 | 52.7 |
| 1952 | 53.1 |
| 1953 | 54.6 |
| 1954 | 52 |
| 1955 | 52 |
| 1956 | 50.9 |
| 1957 | 52.6 |
| 1958 | 50.2 |
| 1959 | 52.6 |
| 1960 | 51.6 |
| 1961 | 51.9 |
| 1962 | 50.5 |
| 1963 | 50.9 |
| 1964 | 51.7 |
| 1965 | 51.4 |
| 1966 | 51.7 |
| 1967 | 50.8 |
| 1968 | 51.9 |
| 1969 | 51.8 |
| 1970 | 51.9 |
| 1971 | 53 |
(let [nhtemp (map #(assoc % :celsius (/ (* 5.0 (- (:value %) 32.0)) 9.0)) (nu/dataset :nhtemp))]
(plot/render-image
(plot/arrange [{:data nhtemp :mapping {:x :time :y :value} :charts [(chart/line) (chart/scatter)]
:labels {:x nil :y "Fahrenheit"}}
{:data nhtemp :mapping {:x :time :y :celsius} :charts [(chart/line) (chart/scatter)]
:labels {:x "Year" :y "Celsius"}}]
{:columns 1 :title "Yearly temperature in New Haven, CT"})
{:width 900 :height 450}))
38.9 Chapter 9 - Labels and Legends
38.9.1 Fig 9.1 Groups and a legend
1993 cars: price against engine size, a panel per airbag type (ordered by mean price), coloured by the number of cylinders (the one rotary engine left out); price on a log-2 axis.
Source: Lattice Fig 9.1. Data: Cars on sale in the USA, 1993, R MASS package Cars93 (Lock 1993); licence: GPL-2 | GPL-3 (MASS).
(plot/render-image
{:data (remove #(= "rotary" (:cylinders %)) cars93)
:mapping {:x :engine-size :y :price :color :cylinders :facet :air-bags}
:scales {:y {:kind :log :base 2 :formatter :power}
:facet {:order-by #(stats/mean (map :price %))}
:color {:domain (vec (remove #{"rotary"} (nu/levels :cars93 :cylinders)))}}
:charts [(chart/scatter)]
:facets {:columns 3}
:labels {:x "Engine Size (litres)" :y "Average Price (1000 USD)"}}
{:width 900 :height 400})
38.9.2 Fig 9.2 Two aesthetics, two legends
Cylinders as the point shape, airbags as the fill (none, grey, black - R’s level order), outlined in black.
Source: Lattice Fig 9.2. Data: Cars on sale in the USA, 1993, R MASS package Cars93 (Lock 1993); licence: GPL-2 | GPL-3 (MASS).
(plot/render-image
{:data cars93
:mapping {:x :engine-size :y :price :shape :cylinders :color :air-bags}
:scales {:y {:kind :log :base 2 :formatter :power}
:shape {:domain (nu/levels :cars93 :cylinders) :range [\O \S \A \V \{ \}]}
:color {:domain (nu/levels :cars93 :air-bags) :range [[255 255 255 0] [160 160 160] [0 0 0]]}}
:charts [(chart/scatter {:size 8 :stroke-color :black})]
:labels {:x "EngineSize" :y "Price"}}
{:width 700 :height 450})
38.9.3 Fig 9.3 A heatmap with a dendrogram
US arrest rates scaled per column, the states (rows) ordered by a hierarchical clustering (Canberra distance), its dendrogram on the right. (The book also colours the leaves by region.)
Source: Lattice Fig 9.3. Data: Violent crime rates by US state (1973), R datasets package USArrests (McNeil 1977); licence: Part of R (GPL-2 | GPL-3).
(let [columns [:murder :assault :urban-pop :rape]
scaled (fn [k] (let [vs (map k us-arrests) mu (stats/mean vs) sd (stats/stddev vs)] (fn [v] (/ (- v mu) sd))))
scalers (into {} (map (juxt identity scaled) columns))]
(plot/render-image
(plot/clustered-heatmap (for [row us-arrests, k columns] {:state (:state row) :variable (name k) :z ((scalers k) (k row))})
{:row :state :col :variable :value :z :distance :canberra :col-tree? false :tree-size [0.3 0.2]
:scales {:color {:range :spectral-11}}})
{:width 600 :height 800}))
Not reproduced: Figs 9.4 and 9.5 (the book’s figures page has neither an image nor code for them).
38.11 Chapter 11 - Manipulating the trellis Object
38.11.1 Fig 11.1 Linear and log scales side by side
US personal expenditure 1940 - 1960, a panel per category (ordered by the median), stems from 0 on the left, a log-2 axis on the right.
Source: Lattice Fig 11.1. Data: US personal expenditure, 1940-1960, R datasets package USPersonalExpenditure (The World Almanac and Book of Facts 1962); licence: Part of R (GPL-2 | GPL-3).
| category | year | expenditure |
|---|---|---|
| Food and Tobacco | 1940 | 22.2 |
| Household Operation | 1940 | 10.5 |
| Medical and Health | 1940 | 3.53 |
| Personal Care | 1940 | 1.04 |
| Private Education | 1940 | 0.341 |
| Food and Tobacco | 1945 | 44.5 |
| Household Operation | 1945 | 15.5 |
| Medical and Health | 1945 | 5.76 |
| Personal Care | 1945 | 1.98 |
| Private Education | 1945 | 0.974 |
| Food and Tobacco | 1950 | 59.6 |
| Household Operation | 1950 | 29 |
| Medical and Health | 1950 | 9.71 |
| Personal Care | 1950 | 2.45 |
| Private Education | 1950 | 1.8 |
| Food and Tobacco | 1955 | 73.2 |
| Household Operation | 1955 | 36.5 |
| Medical and Health | 1955 | 14 |
| Personal Care | 1955 | 3.4 |
| Private Education | 1955 | 2.6 |
| Food and Tobacco | 1960 | 86.8 |
| Household Operation | 1960 | 46.2 |
| Medical and Health | 1960 | 21.1 |
| Personal Care | 1960 | 5.4 |
| Private Education | 1960 | 3.64 |
(let [expenditure {:data (nu/dataset :us-personal-expenditure)
:mapping {:x :expenditure :y :year :facet :category}
:scales {:facet {:order-by #(stats/median (map :expenditure %)) :descending true}}
:facets {:columns 1}
:labels {:x "Expenditure (billion dollars)" :y nil}}]
(plot/render-image
(plot/arrange [(assoc expenditure :charts [(chart/segment {:xend 0}) (chart/scatter)])
(-> expenditure
(assoc :charts [(chart/scatter)])
(assoc-in [:scales :x] {:kind :log :base 2}))]
{:columns 2})
{:width 800 :height 800}))
38.11.2 Fig 11.2 Panel heights
Days of frost per state, a panel per region (ordered by mean frost), the states by frost within each (free y); each panel as tall as its number of states.
Source: Lattice Fig 11.2. Data: US state facts (1970s), R datasets packages state.x77, state.name, state.abb, state.region, state.division, state.center (US Census); licence: Part of R (GPL-2 | GPL-3).
(def frost-plot
{:data states
:mapping {:x :frost :y :name :facet :region}
:scales {:y {:order-by #(stats/mean (map :frost %))} :facet {:order-by #(stats/mean (map :frost %)) :descending true}}
:charts [(chart/scatter)]
:facets {:columns 1 :scales {:y :free}}
:theme {:text {:tick-label {:size 8}}}
:labels {:x "Frost" :y nil}})(let [counts (frequencies (map :region states))
order (sort-by (fn [r] (- (stats/mean (map :frost (filter #(= r (:region %)) states))))) (keys counts))]
(plot/render-image (assoc-in frost-plot [:facets :heights] (mapv counts order)) {:width 600 :height 800}))
38.11.3 Fig 11.3 One panel
Source: Lattice Fig 11.3. Data: US state facts (1970s), R datasets packages state.x77, state.name, state.abb, state.region, state.division, state.center (US Census); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image (assoc frost-plot :data (filterv #(= "West" (:region %)) states)) {:width 700 :height 450})
38.11.4 Fig 11.4 Twelve views
The quakes cloud turned 0 - 30 degrees about the vertical and tilted from above (elevation 90) to nearly side-on (10), step by step.
Source: Lattice Fig 11.4. Data: Earthquakes off Fiji since 1964, R datasets package quakes (Harvard PRIM-H project); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
(plot/arrange (for [i (range 12)]
{:data quakes
:mapping {:x :long :y :lat :z :depth}
:charts [(chart/cloud {:domain {:z [690 30]} :axes false :size 2
:view {:azimuth (* -30.0 (/ i 11.0)) :elevation (- 90.0 (* 80.0 (/ i 11.0))) :distance 0.2}})]})
{:columns 4})
{:width 900 :height 700})
38.11.5 Fig 11.5 Tukey mean-difference plot
The two-sample Q-Q plot of Fig 3.10 turned 45 degrees: the difference of each pair of quantiles (girls minus boys) against their mean, per A-level score.
Source: Lattice Fig 11.5. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(let [ps (mapv #(/ (- % 0.5) 100.0) (range 1 101))
quantiles (fn [rows] (stats/quantiles (map :gcsescore rows) ps))]
(plot/render-image
{:data (for [[score rows] (group-by :score chem97)
:let [by-gender (group-by :gender rows)]
[f mq] (map vector (quantiles (by-gender "F")) (quantiles (by-gender "M")))]
{:score score :mean (/ (+ f mq) 2.0) :difference (- f mq)})
:mapping {:x :mean :y :difference :facet :score}
:charts [(chart/scatter {:shape \o :size 5})]
:facets {:columns 3}
:labels {:x "mean" :y "difference"}}
{:width 800 :height 500}))
38.11.6 Fig 11.6 Outer strips
Hourly accesses of the Bioconductor website (log10) by hour of day, a panel per month (columns) and weekday (rows), with the mean per hour.
Source: Lattice Fig 11.6. Data: Hourly accesses of the Bioconductor website, 2007, R latticeExtra package biocAccess (Bioconductor web logs); licence: GPL (>= 2) (latticeExtra).
(let [rows (map #(assoc % :log-counts (m/log10 (:counts %))) (nu/dataset :bioc-access))
means (for [[[month weekday hour] rs] (group-by (juxt :month :weekday :hour) rows)]
{:month month :weekday weekday :hour hour :log-counts (stats/mean (map :log-counts rs))})
months (vec (filter (set (map :month rows)) (nu/levels :bioc-access :month)))]
(plot/render-image
{:data rows
:mapping {:x :hour :y :log-counts :facet-col :month :facet-row :weekday}
:scales {:facet-col {:domain months} :facet-row {:domain (nu/levels :bioc-access :weekday)}}
:charts [(chart/scatter {:size 2}) (chart/line {:data means :color :black})]
:theme {:text {:strip {:size 9}}}
:labels {:x "hour" :y "log10(counts)"}}
{:width 1000 :height 800}))
38.12 Chapter 12 - Interactive Displays
Not reproduced: the chapter’s figures - they show interaction with a displayed plot (identifying points, editing it on screen); cljplot2 draws static images.
38.13 Chapter 13 - Advanced Panel Functions
(defn- hypotrochoid
"Points `{:x :y}` of a hypotrochoid in the unit circle (lattice's `panel.hypotrochoid`): a circle of radius `r`
rolling inside it, the pen `d` from its centre, over `cycles` turns at `density` points per turn, in drawing order."
[r d cycles density]
(let [r (double r) d (double d) a (- 1.0 r)]
(for [i (range (inc (* (long cycles) (long density))))
:let [t (* m/TWO_PI (/ (double i) (double density)))]]
{:x (+ (* a (m/cos t)) (* d (m/cos (/ (* a t) r))))
:y (- (* a (m/sin t)) (* d (m/sin (/ (* a t) r))))})))#'galleries.lattice/hypotrochoid38.13.1 Fig 13.1 Hypocycloids
A panel per ratio k = p / 10 of the fixed to the rolling circle (p = 11 … 30): the rolling circle of radius 1/k traced from its rim over 10 turns. Panels run top-down here (lattice fills them bottom-up).
Source: Lattice Fig 13.1.
(let [ratio-text (fn [p] (let [k (/ (double p) 10.0)] (if (== k (m/floor k)) (str (long k)) (str k))))
ps (range 11 31)]
(plot/render-image
{:data (for [p ps, point (hypotrochoid (/ 10.0 p) (/ 10.0 p) 10 30)] (assoc point :k (ratio-text p)))
:mapping {:x :x :y :y :facet :k}
:scales {:facet {:domain (mapv ratio-text ps)}
:x {:domain [-1 1] :axis false} :y {:domain [-1 1] :axis false}}
:charts [(chart/line {:sort false :width 0.8})]
:facets {:columns 4}
:aspect :iso
:labels {:x nil :y nil}}
{:width 650 :height 800}))
38.13.2 Fig 13.2 Random hypotrochoids
42 hypotrochoids of random rolling radius r in [0.25, 0.75] and pen distance d in [r/4, r], 15 turns each.
Source: Lattice Fig 13.2.
(let [rng (r/rng :mersenne 20070706)]
(plot/render-image
(plot/arrange
(vec (repeatedly 42 (fn []
(let [radius (r/drandom rng 0.25 0.75)
d (r/drandom rng (* 0.25 radius) radius)]
{:data (hypotrochoid radius d 15 30)
:mapping {:x :x :y :y}
:scales {:x {:domain [-1 1] :axis false} :y {:domain [-1 1] :axis false}}
:charts [(chart/line {:sort false :width 0.5})]
:theme {:panel {:grid {:x :none :y :none}}}
:aspect :iso
:labels {:x nil :y nil}}))))
{:columns 6})
{:width 800 :height 800}))
38.13.3 Fig 13.3 Densities by eruption length
Waiting time to the next Old Faithful eruption, a panel per eruption length interval (four equal-count, half-overlapping); a kernel density in place of the book’s logspline fit.
Source: Lattice Fig 13.3. Data: Old Faithful geyser eruptions, R datasets package faithful (Härdle 1991; Azzalini & Bowman 1990); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data (shingle/shingle faithful :eruptions {:count 4 :overlap 0.5 :as :eruption-length :label "Eruptions"})
:mapping {:x :waiting :facet :eruption-length}
:charts [(chart/density)]
:facets {:columns 4}
:labels {:x "waiting"}}
{:width 900 :height 350})
38.13.4 Fig 13.4 Tufte’s quartile plot
Transformed GCSE score by gender, a panel per A-level score: the median as a point, the whiskers as lines, no box and no outliers (as the book’s panel.bwtufte).
Source: Lattice Fig 13.4. Data: A-level chemistry scores, England 1997, R mlmRev package Chem97 (Yang et al. 2002); licence: GPL (>= 2) (mlmRev).
(plot/render-image
{:data chem97-trans
:mapping {:x :gender :y :gcsescore-trans :facet :score}
:charts [(chart/box {:variant :tufte :outliers false})]
:facets {:columns 6}
:labels {:x nil :y "Transformed GCSE score"}}
{:width 900 :height 400})
(def cars93-cluster-order
"The numeric Cars93 columns (keywords) in the order of a complete-linkage clustering of the rows of their
correlation matrix (euclidean distance; R `order.dendrogram(as.dendrogram(hclust(dist(cor))))`)."
(let [names (vec (distinct (map :row cars93-correlations)))
r (into {} (map (juxt (juxt :row :column) :r)) cars93-correlations)
matrix (mapv (fn [a] (mapv (fn [b] (r [a b])) names)) names)]
(mapv (comp keyword :name) (tree/leaves (tree/from-hclust (cl/hclust matrix {:method :complete}) names)))))(def cars93-short-names
"Names of the numeric Cars93 columns short enough for a strip of the 18 x 18 grid."
{:min-price "min-price" :price "price" :max-price "max-price" :mpg-city "mpg-city" :mpg-highway "mpg-hwy"
:engine-size "engine" :horsepower "hp" :rpm "rpm" :rev-per-mile "rev/mile" :fuel-tank-capacity "tank"
:passengers "passengers" :length "length" :wheelbase "wheelbase" :width "width" :turn-circle "turn"
:rear-seat-room "rear-seat" :luggage-room "luggage" :weight "weight"})(def cars93-pairs
"Every ordered pair of the numeric Cars93 columns with every car's two values: `{:a :b :x :y}` (short column
names; a missing value stays `nil` - the correlation glyph uses the complete pairs)."
(vec (for [a cars93-cluster-order, b cars93-cluster-order, row cars93]
{:a (cars93-short-names a) :b (cars93-short-names b) :x (a row) :y (b row)})))| a | b | x | y |
|---|---|---|---|
| rpm | rpm | 6300 | 6300 |
| rpm | rpm | 5500 | 5500 |
| rpm | rpm | 5500 | 5500 |
| rpm | rpm | 5500 | 5500 |
| rpm | rpm | 5700 | 5700 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 4000 | 4000 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 4100 | 4100 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 4600 | 4600 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 4000 | 4000 |
| rpm | rpm | 4200 | 4200 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 5300 | 5300 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 5800 | 5800 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 6500 | 6500 |
| rpm | rpm | 4200 | 4200 |
| rpm | rpm | 4600 | 4600 |
| rpm | rpm | 5500 | 5500 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 4200 | 4200 |
| rpm | rpm | 5700 | 5700 |
| rpm | rpm | 5400 | 5400 |
| rpm | rpm | 5800 | 5800 |
| rpm | rpm | 5900 | 5900 |
| rpm | rpm | 5600 | 5600 |
| rpm | rpm | 5500 | 5500 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 5550 | 5550 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 4400 | 4400 |
| rpm | rpm | 4600 | 4600 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 5500 | 5500 |
| rpm | rpm | 5600 | 5600 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 6500 | 6500 |
| rpm | rpm | 5100 | 5100 |
| rpm | rpm | 5500 | 5500 |
| rpm | rpm | 5750 | 5750 |
| rpm | rpm | 3800 | 3800 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 5600 | 5600 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 5600 | 5600 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 4600 | 4600 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 4800 | 4800 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 5600 | 5600 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 5600 | 5600 |
| rpm | rpm | 6000 | 6000 |
| rpm | rpm | 5200 | 5200 |
| rpm | rpm | 5400 | 5400 |
| rpm | rpm | 5400 | 5400 |
| rpm | rpm | 5000 | 5000 |
| rpm | rpm | 5500 | 5500 |
| rpm | rpm | 4500 | 4500 |
| rpm | rpm | 5800 | 5800 |
| rpm | rpm | 5800 | 5800 |
| rpm | rpm | 5400 | 5400 |
| rpm | rpm | 6200 | 6200 |
| rpm | rev/mile | 6300 | 2890 |
| rpm | rev/mile | 5500 | 2335 |
| rpm | rev/mile | 5500 | 2280 |
| rpm | rev/mile | 5500 | 2535 |
| rpm | rev/mile | 5700 | 2545 |
| rpm | rev/mile | 5200 | 2565 |
| rpm | rev/mile | 4800 | 1570 |
| … | … | … | … |
38.13.5 Fig 13.5 Correlation ellipses
The Cars93 correlations (6.12) in clustered order, each pair as the ellipse of a bivariate normal with that correlation, colored by it (the book also prints 100 r inside): a facet grid of correlation glyphs - plot/pairs needs larger cells for 18 variables.
Source: Lattice Fig 13.5. Data: Cars on sale in the USA, 1993, R MASS package Cars93 (Lock 1993); licence: GPL-2 | GPL-3 (MASS).
(let [names (mapv cars93-short-names cars93-cluster-order)]
(plot/render-image
{:data cars93-pairs
:mapping {:x :x :y :y :facet-row :a :facet-col :b}
:scales {:facet-row {:domain names} :facet-col {:domain names}
:x {:domain [0 1] :axis false} :y {:domain [0 1] :axis false}}
:charts [(chart/correlation {:glyph :ellipse})]
:theme {:text {:strip {:size 7}}}
:labels {:x nil :y nil}}
{:width 1000 :height 800}))
38.13.6 Fig 13.6 Correlation pies
The same matrix, each correlation as a filled share of a disk: clockwise for positive, counter-clockwise for negative.
Source: Lattice Fig 13.6. Data: Cars on sale in the USA, 1993, R MASS package Cars93 (Lock 1993); licence: GPL-2 | GPL-3 (MASS).
(let [names (mapv cars93-short-names cars93-cluster-order)]
(plot/render-image
{:data cars93-pairs
:mapping {:x :x :y :y :facet-row :a :facet-col :b}
:scales {:facet-row {:domain names} :facet-col {:domain names}
:x {:domain [0 1] :axis false} :y {:domain [0 1] :axis false}}
:charts [(chart/correlation {:glyph :pie})]
:theme {:text {:strip {:size 7}}}
:labels {:x nil :y nil}}
{:width 1000 :height 800}))
38.13.7 Fig 13.7 Contours on a wireframe
Maunga Whau’s heights as a shaded surface with their contour lines (every 10 m) on the top of the box, as dense points of a cloud over the surface - cljplot2 has no 3D lines.
Source: Lattice Fig 13.7. Data: Maunga Whau volcano topography, R datasets package volcano (Ross Ihaka); licence: Part of R (GPL-2 | GPL-3).
(defn- volcano-contour-points
"Points every tenth of a grid step along the contour lines of the volcano heights at 100, 110, ... 190 m, at
height `top`: rows `{:row :column :height}` (the grid - every row x column of `volcano`)."
[top]
(let [nx (long (reduce max (map :row volcano))) ny (long (reduce max (map :column volcano)))
heights (into {} (map (juxt (juxt :row :column) :height)) volcano)
grid {:xs (double-array (range 1 (inc nx))) :ys (double-array (range 1 (inc ny))) :nx nx :ny ny
:values (double-array (for [j (range 1 (inc ny)) i (range 1 (inc nx))] (heights [i j])))}]
(vec (for [level (range 100 200 10)
{:keys [points closed?]} (contour/isolines grid level)
[[x0 y0] [x1 y1]] (partition 2 1 (cond-> points closed? (conj (first points))))
f (range 0.0 1.0 0.1)]
{:row (+ x0 (* f (- x1 x0))) :column (+ y0 (* f (- y1 y0))) :height top}))))#'galleries.lattice/volcano-contour-points(let [domain {:x [1 87] :y [1 61] :z [90 250]}
view {:azimuth -20 :elevation 30 :distance 0.2}]
(plot/render-image
{:data volcano
:mapping {:x :row :y :column :z :height}
:scales {:color {:range [[0 166 0] [230 230 0] [236 177 118] [242 242 242]]}}
:charts [(chart/surface {:domain domain :view view :aspect [1 (/ 61.0 87.0) 0.3] :axes false})
(chart/cloud {:data (volcano-contour-points (second (:z domain))) :domain domain :size 1.2
:color [40 40 40]})]
:labels {:x nil :y nil}}
{:width 800 :height 550}))
Not reproduced: Figs 13.8 - 13.10 (maps).
38.14 Chapter 14 - New Trellis Displays
38.14.1 Fig 14.1 A cut time series
Yearly sunspot numbers cut into four slightly overlapping periods of equal length (sliced x scales, in place of banking), one above another; the strips on top (lattice puts them on the left).
Source: Lattice Fig 14.1. Data: Yearly sunspot numbers, 1700-1988, R datasets package sunspot.year (WDC-SILSO, Royal Observatory of Belgium); licence: Part of R (GPL-2 | GPL-3).
| time | value |
|---|---|
| 1700 | 5 |
| 1701 | 11 |
| 1702 | 16 |
| 1703 | 23 |
| 1704 | 36 |
| 1705 | 58 |
| 1706 | 29 |
| 1707 | 20 |
| 1708 | 10 |
| 1709 | 8 |
| 1710 | 3 |
| 1711 | 0 |
| 1712 | 0 |
| 1713 | 2 |
| 1714 | 11 |
| 1715 | 27 |
| 1716 | 47 |
| 1717 | 63 |
| 1718 | 60 |
| 1719 | 39 |
| 1720 | 28 |
| 1721 | 26 |
| 1722 | 22 |
| 1723 | 11 |
| 1724 | 21 |
| 1725 | 40 |
| 1726 | 78 |
| 1727 | 122 |
| 1728 | 103 |
| 1729 | 73 |
| 1730 | 47 |
| 1731 | 35 |
| 1732 | 11 |
| 1733 | 5 |
| 1734 | 16 |
| 1735 | 34 |
| 1736 | 70 |
| 1737 | 81 |
| 1738 | 111 |
| 1739 | 101 |
| 1740 | 73 |
| 1741 | 40 |
| 1742 | 20 |
| 1743 | 16 |
| 1744 | 5 |
| 1745 | 11 |
| 1746 | 22 |
| 1747 | 40 |
| 1748 | 60 |
| 1749 | 80.9 |
| 1750 | 83.4 |
| 1751 | 47.7 |
| 1752 | 47.8 |
| 1753 | 30.7 |
| 1754 | 12.2 |
| 1755 | 9.6 |
| 1756 | 10.2 |
| 1757 | 32.4 |
| 1758 | 47.6 |
| 1759 | 54 |
| 1760 | 62.9 |
| 1761 | 85.9 |
| 1762 | 61.2 |
| 1763 | 45.1 |
| 1764 | 36.4 |
| 1765 | 20.9 |
| 1766 | 11.4 |
| 1767 | 37.8 |
| 1768 | 69.8 |
| 1769 | 106.1 |
| 1770 | 100.8 |
| 1771 | 81.6 |
| 1772 | 66.5 |
| 1773 | 34.8 |
| 1774 | 30.6 |
| 1775 | 7 |
| 1776 | 19.8 |
| 1777 | 92.5 |
| 1778 | 154.4 |
| 1779 | 125.9 |
| 1780 | 84.8 |
| 1781 | 68.1 |
| 1782 | 38.5 |
| 1783 | 22.8 |
| 1784 | 10.2 |
| 1785 | 24.1 |
| 1786 | 82.9 |
| 1787 | 132 |
| 1788 | 130.9 |
| 1789 | 118.1 |
| 1790 | 89.9 |
| 1791 | 66.6 |
| 1792 | 60 |
| 1793 | 46.9 |
| 1794 | 41 |
| 1795 | 21.3 |
| 1796 | 16 |
| 1797 | 6.4 |
| 1798 | 4.1 |
| 1799 | 6.8 |
| … | … |
(plot/render-image
{:data (shingle/shingle (nu/dataset :sunspot-year) :time {:count 4 :overlap 0.05 :as :period :label "Time"})
:mapping {:x :time :y :value :facet :period}
:charts [(chart/line)]
:facets {:columns 1 :scales {:x :sliced}}
:labels {:x "Time" :y "sunspot.year"}}
{:width 1000 :height 700})
38.14.2 Fig 14.2 Seasonal decomposition
Two months of hourly Bioconductor accesses as data = seasonal + trend + remainder: the seasonal part the mean daily profile, the trend a loess of the rest over 37 hours - stl’s trend window for a 24-hour period (a simple decomposition in place of the book’s stl).
Source: Lattice Fig 14.2. Data: Hourly accesses of the Bioconductor website, 2007, R latticeExtra package biocAccess (Bioconductor web logs); licence: GPL (>= 2) (latticeExtra).
(let [counts (mapv (comp double :counts) (take (* 24 30 2) (nu/dataset :bioc-access)))
n (count counts)
days (mapv #(+ 1.0 (/ (double %) 24.0)) (range n))
trend-of (fn [ys] (let [f (interp/loess days ys {:bandwidth (/ 37.0 n) :iters 0})] (mapv f days)))
profile (fn [ys] (let [by-hour (group-by #(mod (long %) 24) (range n))
means (update-vals by-hour #(stats/mean (map ys %)))
level (stats/mean (vals means))]
(mapv #(- (double (means (mod (long %) 24))) level) (range n))))
seasonal (profile (mapv - counts (trend-of counts)))
trend (trend-of (mapv - counts seasonal))
remainder (mapv - counts seasonal trend)]
(plot/render-image
{:data (for [[component values] [["data" counts] ["seasonal" seasonal] ["trend" trend] ["remainder" remainder]]
i (range n)]
{:component component :day (days i) :value (values i)})
:mapping {:x :day :y :value :facet :component}
:scales {:facet {:domain ["data" "seasonal" "trend" "remainder"]}}
:charts [(chart/line {:width 0.6})]
:facets {:columns 1 :scales {:y :free}}
:labels {:x "Time (Days)" :y nil}}
{:width 1000 :height 700}))
38.14.3 Fig 14.3 Densities by visit
Forward scatter (FSC-H) of the GvHD cells, a ridge per visit, a panel per patient (flowViz’s density plot).
Source: Lattice Fig 14.3. Data: Flow cytometry of GvHD patients (FSC-H), R flowCore package GvHD (Brinkman et al. 2007); licence: Artistic-2.0 (flowCore).
| patient | visit | fsc-h |
|---|---|---|
| 5 | 1 | 371 |
| 5 | 1 | 190 |
| 5 | 1 | 141 |
| 5 | 1 | 167 |
| 5 | 1 | 128 |
| 5 | 1 | 208 |
| 5 | 1 | 172 |
| 5 | 1 | 236 |
| 5 | 1 | 353 |
| 5 | 1 | 85 |
| 5 | 1 | 407 |
| 5 | 1 | 233 |
| 5 | 1 | 234 |
| 5 | 1 | 107 |
| 5 | 1 | 130 |
| 5 | 1 | 286 |
| 5 | 1 | 261 |
| 5 | 1 | 137 |
| 5 | 1 | 411 |
| 5 | 1 | 141 |
| 5 | 1 | 188 |
| 5 | 1 | 222 |
| 5 | 1 | 206 |
| 5 | 1 | 140 |
| 5 | 1 | 224 |
| 5 | 1 | 60 |
| 5 | 1 | 130 |
| 5 | 1 | 95 |
| 5 | 1 | 168 |
| 5 | 1 | 129 |
| 5 | 1 | 192 |
| 5 | 1 | 136 |
| 5 | 1 | 237 |
| 5 | 1 | 591 |
| 5 | 1 | 285 |
| 5 | 1 | 321 |
| 5 | 1 | 326 |
| 5 | 1 | 213 |
| 5 | 1 | 220 |
| 5 | 1 | 154 |
| 5 | 1 | 177 |
| 5 | 1 | 60 |
| 5 | 1 | 131 |
| 5 | 1 | 101 |
| 5 | 1 | 131 |
| 5 | 1 | 342 |
| 5 | 1 | 111 |
| 5 | 1 | 389 |
| 5 | 1 | 216 |
| 5 | 1 | 83 |
| 5 | 1 | 466 |
| 5 | 1 | 157 |
| 5 | 1 | 186 |
| 5 | 1 | 59 |
| 5 | 1 | 113 |
| 5 | 1 | 181 |
| 5 | 1 | 102 |
| 5 | 1 | 318 |
| 5 | 1 | 257 |
| 5 | 1 | 99 |
| 5 | 1 | 105 |
| 5 | 1 | 70 |
| 5 | 1 | 156 |
| 5 | 1 | 464 |
| 5 | 1 | 129 |
| 5 | 1 | 371 |
| 5 | 1 | 61 |
| 5 | 1 | 113 |
| 5 | 1 | 748 |
| 5 | 1 | 232 |
| 5 | 1 | 60 |
| 5 | 1 | 143 |
| 5 | 1 | 365 |
| 5 | 1 | 266 |
| 5 | 1 | 404 |
| 5 | 1 | 105 |
| 5 | 1 | 75 |
| 5 | 1 | 278 |
| 5 | 1 | 97 |
| 5 | 1 | 74 |
| 5 | 1 | 251 |
| 5 | 1 | 275 |
| 5 | 1 | 62 |
| 5 | 1 | 123 |
| 5 | 1 | 87 |
| 5 | 1 | 403 |
| 5 | 1 | 64 |
| 5 | 1 | 81 |
| 5 | 1 | 188 |
| 5 | 1 | 1023 |
| 5 | 1 | 185 |
| 5 | 1 | 115 |
| 5 | 1 | 558 |
| 5 | 1 | 168 |
| 5 | 1 | 180 |
| 5 | 1 | 431 |
| 5 | 1 | 219 |
| 5 | 1 | 371 |
| 5 | 1 | 482 |
| 5 | 1 | 275 |
| … | … | … |
(plot/render-image
{:data (nu/dataset :gvhd)
:mapping {:x :fsc-h :y (levels/categorical :visit) :color (levels/categorical :visit) :facet :patient}
:scales {:facet {:domain (nu/levels :gvhd :patient)}}
:charts [(chart/density)]
:facets {:columns 3}
:legend false
:labels {:x "FSC-H" :y "Visit"}}
{:width 900 :height 700})
38.14.4 Fig 14.4 Hexagonal binning
Hemoglobin by total iron-binding capacity in NHANES, counted in hexagons, a panel per sex.
Source: Lattice Fig 14.4. Data: NHANES I: iron and anemia, R hexbin package NHANES (National Health and Nutrition Examination Survey); licence: GPL-2 (hexbin).
| cancer-incidence | cancer-death | age | smoke | ed | race | weight | bmi | diet-iron | albumin | serum-iron | tibc | transferin | hemoglobin | sex |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| No | No | 46 | Nonsmoker | 0 | 0 | 82.7 | 29.4 | 12.5 | 4.8 | 14.7 | M | |||
| No | No | 72 | Unknown | 0 | 0 | 85.6 | 29.6 | 4.1 | 14.5 | M | ||||
| No | No | 53 | Past | 1 | 1 | 71.5 | 23.1 | 14.8 | 135 | 334 | 40.4 | 16.8 | M | |
| No | No | 49 | Unknown | 0 | 1 | 93.8 | 30 | 24.3 | 4.3 | 85 | 385 | 22.1 | 16 | M |
| No | No | 31 | Current | 0 | 1 | 81.6 | 29.7 | 11.8 | 4.3 | 104 | 436 | 23.9 | 16.1 | M |
| No | No | 42 | Current | 1 | 1 | 68.3 | 21.9 | 25.3 | 4.8 | 124 | 285 | 43.5 | 17.1 | M |
| No | No | 27 | Current | 0 | 0 | 67.7 | 26.3 | 25.2 | 4.3 | 68 | 468 | 14.5 | 14.3 | M |
| No | No | 64 | Unknown | 0 | 0 | 86.5 | 31.9 | 6.8 | 3.9 | 15 | M | |||
| No | No | 37 | Nonsmoker | 1 | 0 | 61.7 | 20.9 | 26.2 | 4.4 | 69 | 291 | 23.7 | 15.2 | M |
| No | No | 42 | Past | 1 | 1 | 85 | 26.7 | 11 | 4.7 | 89 | 456 | 19.5 | 16.3 | M |
| No | No | 65 | Current | 1 | 1 | 70.2 | 23.7 | 6.5 | 4 | 101 | 358 | 28.2 | 16.1 | M |
| No | No | 57 | Current | 0 | 1 | 89.6 | 26.9 | 34 | 4 | 162 | 369 | 43.9 | 18.2 | M |
| No | No | 53 | Current | 0 | 0 | 63.2 | 20.7 | 8 | 138 | 302 | 45.7 | 16.4 | M | |
| No | No | 68 | Past | 0 | 0 | 93 | 30.8 | 13.7 | 4.4 | 60 | 304 | 19.7 | 13.9 | M |
| No | No | 60 | Current | 0 | 0 | 80.6 | 27.6 | 4 | 313 | 16.8 | M | |||
| No | No | 34 | Nonsmoker | 1 | 1 | 71.7 | 21 | 12.7 | 4.4 | 16 | M | |||
| No | No | 53 | Unknown | 0 | 0 | 66.8 | 23.7 | 4.5 | 4.1 | 94 | 339 | 27.7 | 14.5 | M |
| No | No | 41 | Current | 0 | 0 | 68.7 | 26.5 | 15.6 | 4.8 | 111 | 351 | 31.6 | 15.4 | M |
| No | No | 31 | Current | 0 | 1 | 85.4 | 27 | 22.6 | 4.4 | 129 | 433 | 29.8 | 16.6 | M |
| No | No | 73 | Nonsmoker | 0 | 1 | 56.8 | 24.9 | 9.9 | 3.9 | 95 | 309 | 30.7 | 15.8 | M |
| No | No | 66 | Nonsmoker | 0 | 1 | 62.4 | 24.5 | 19.2 | 3.9 | 14.8 | M | |||
| Yes | Yes | 65 | Unknown | 0 | 1 | 81.3 | 26.6 | 21.4 | 4.1 | 214 | 236 | 90.7 | 17.1 | M |
| No | No | 43 | Current | 0 | 1 | 103.9 | 30.8 | 13.7 | 4.6 | 149 | 443 | 33.6 | 17.7 | M |
| No | No | 69 | Nonsmoker | 0 | 1 | 97.8 | 30.9 | 15.7 | 3.6 | 134 | 303 | 44.2 | 16.1 | M |
| No | No | 62 | Past | 1 | 1 | 74.8 | 24.9 | 23.9 | 4.4 | 114 | 314 | 36.3 | 15.7 | M |
| No | No | 26 | Current | 0 | 0 | 75.4 | 26.2 | 40.9 | 4.6 | 301 | 14.6 | M | ||
| No | No | 44 | Unknown | 0 | 1 | 81.3 | 28.2 | 11.7 | 142 | 349 | 40.7 | 16.3 | M | |
| Yes | Yes | 54 | Unknown | 0 | 0 | 78 | 24.3 | 3.8 | 4.1 | 144 | 334 | 43.1 | 17.3 | M |
| No | No | 42 | Current | 0 | 0 | 79 | 26 | 21.5 | 4.9 | 77 | 340 | 22.6 | 15.1 | M |
| No | No | 35 | Current | 0 | 1 | 58.6 | 23.1 | 35.1 | 5.4 | 87 | 342 | 25.4 | 15.1 | M |
| Yes | Yes | 68 | Past | 0 | 1 | 71.5 | 22.7 | 20.7 | 4.2 | 15.4 | M | |||
| No | No | 54 | Current | 0 | 0 | 74.7 | 28.3 | 20.5 | 4.6 | 97 | 299 | 32.4 | 14 | M |
| No | No | 68 | Current | 0 | 0 | 59.4 | 20.5 | 6.1 | 3.1 | 14.4 | M | |||
| No | No | 53 | Past | 0 | 0 | 84.3 | 25.9 | 11.6 | 3.8 | 15.4 | M | |||
| No | No | 67 | Nonsmoker | 0 | 0 | 64.9 | 22.6 | 7.2 | 3.8 | 268 | 12.1 | M | ||
| No | No | 60 | Unknown | 0 | 0 | 73.8 | 21.5 | 3.9 | 72 | 316 | 22.8 | 12.5 | M | |
| No | No | 40 | Current | 0 | 1 | 87.1 | 26.3 | 16.4 | 4.5 | 69 | 316 | 21.8 | 15 | M |
| No | No | 49 | Current | 1 | 0 | 82.3 | 22.2 | 11.5 | 124 | 267 | 46.4 | 14.3 | M | |
| No | No | 31 | Current | 0 | 0 | 67.9 | 25.3 | 12 | 92 | 356 | 25.8 | 16.7 | M | |
| No | No | 48 | Nonsmoker | 0 | 1 | 67.9 | 26.7 | 24.9 | 4.6 | 101 | 307 | 32.9 | 18.6 | M |
| No | No | 69 | Past | 0 | 1 | 70.1 | 25.6 | 24.4 | 5.5 | 114 | 344 | 33.1 | 16.7 | M |
| No | No | 38 | Nonsmoker | 0 | 1 | 71.8 | 27.1 | 14.4 | 70 | 302 | 23.2 | 16.9 | M | |
| Yes | Yes | 51 | Unknown | 1 | 1 | 66.2 | 21.7 | 66.5 | 4.6 | 15.6 | M | |||
| No | No | 55 | Nonsmoker | 0 | 1 | 78.7 | 25 | 13.5 | 4.5 | 115 | 403 | 28.5 | M | |
| No | No | 26 | Current | 0 | 1 | 79.7 | 23.5 | 20.3 | 4.5 | 221 | 363 | 60.9 | 15.5 | M |
| Yes | Yes | 69 | Past | 0 | 1 | 73.1 | 26.4 | 22.6 | 269 | 14.2 | M | |||
| Yes | Yes | 65 | Unknown | 0 | 1 | 83 | 28.2 | 32.3 | 3.9 | 144 | 340 | 42.4 | 16.7 | M |
| No | No | 29 | Unknown | 0 | 1 | 69 | 22.5 | 5 | 178 | 411 | 43.3 | M | ||
| No | No | 70 | Past | 0 | 1 | 85.6 | 30.3 | 17 | 4.2 | 138 | 302 | 45.7 | 13.1 | M |
| No | No | 66 | Nonsmoker | 0 | 1 | 86.2 | 30.8 | 8.6 | 4 | 120 | 290 | 41.4 | 15 | M |
| No | No | 70 | Past | 0 | 1 | 74.8 | 28.5 | 9.6 | 4.2 | 165 | 296 | 55.7 | M | |
| Yes | No | 57 | Nonsmoker | 0 | 1 | 77.9 | 23.6 | 14.9 | 76 | 338 | 22.5 | 14.8 | M | |
| No | No | 69 | Nonsmoker | 0 | 0 | 62.5 | 23.2 | 12 | 72 | 373 | 19.3 | 14.4 | M | |
| No | No | 72 | Past | 0 | 1 | 49.5 | 17.9 | 14.4 | 4.2 | 110 | 324 | 34 | M | |
| No | No | 48 | Unknown | 1 | 1 | 67.9 | 26.7 | 7.8 | 4.5 | 110 | 388 | 28.4 | 14.9 | M |
| No | No | 67 | Nonsmoker | 0 | 1 | 73.3 | 24.6 | 11.2 | 158 | 359 | 44 | 15.3 | M | |
| No | No | 72 | Nonsmoker | 0 | 1 | 72.6 | 24 | 8.1 | 4.2 | 65 | 290 | 22.4 | 13.9 | M |
| No | No | 26 | Current | 0 | 1 | 89.2 | 34.2 | 5.5 | 4.5 | 138 | 358 | 38.5 | 16.4 | M |
| No | No | 51 | Current | 0 | 1 | 64.9 | 23.3 | 13.7 | 4.3 | 78 | 325 | 24 | 15 | M |
| No | No | 43 | Past | 0 | 1 | 62.3 | 20.3 | 4.8 | 165 | 475 | 34.7 | 15.6 | M | |
| No | No | 31 | Past | 1 | 1 | 77.2 | 21.5 | 19.3 | 4.5 | 147 | 350 | 42 | M | |
| Yes | No | 45 | Past | 0 | 1 | 66.8 | 24.9 | 10.1 | 120 | 288 | 41.7 | 14.5 | M | |
| Yes | Yes | 64 | Past | 0 | 1 | 81.6 | 26.6 | 4.2 | 125 | 370 | 33.8 | 16.2 | M | |
| No | No | 43 | Current | 0 | 1 | 64 | 20.5 | 6.9 | 5.1 | 358 | 16.8 | M | ||
| No | No | 34 | Current | 0 | 1 | 85.3 | 24.4 | 13.1 | 226 | 378 | 59.8 | 16.4 | M | |
| No | No | 68 | Unknown | 0 | 1 | 73 | 26.7 | 11.5 | 158 | 421 | 37.5 | 15.6 | M | |
| No | No | 67 | Unknown | 0 | 1 | 83.8 | 25.9 | 7.6 | 129 | 264 | 48.9 | 16.5 | M | |
| Yes | Yes | 64 | Nonsmoker | 0 | 1 | 55.8 | 20.1 | 7.9 | 3.5 | 86 | 423 | 20.3 | 14.9 | M |
| No | No | 52 | Past | 0 | 1 | 88.5 | 24.8 | 21 | 4.5 | 141 | 389 | 36.2 | M | |
| No | No | 46 | Current | 0 | 1 | 72.2 | 24.3 | 16.2 | 95 | 352 | 27 | 16.3 | M | |
| No | No | 26 | Nonsmoker | 1 | 1 | 90.5 | 27.3 | 7.4 | 4.7 | 81 | 400 | 20.3 | M | |
| No | No | 59 | Nonsmoker | 0 | 1 | 74.7 | 27.6 | 19.4 | 4.5 | 74 | 340 | 21.8 | 17 | M |
| No | No | 71 | Current | 0 | 1 | 84.9 | 26.3 | 6.7 | 4 | 93 | 330 | 28.2 | 14.3 | M |
| Yes | Yes | 43 | Current | 0 | 1 | 63.3 | 21.1 | 11 | 4.5 | 105 | 349 | 30.1 | 15.8 | M |
| No | No | 71 | Nonsmoker | 0 | 1 | 69.2 | 24.7 | 15.9 | 4.5 | 124 | 382 | 32.5 | M | |
| No | No | 56 | Current | 0 | 1 | 76.7 | 26.8 | 15.1 | 92 | 374 | 24.6 | 16.8 | M | |
| No | No | 31 | Nonsmoker | 0 | 1 | 86.3 | 26.5 | 16.4 | 4.7 | 337 | 17.5 | M | ||
| No | No | 74 | Current | 0 | 1 | 77.9 | 27.1 | 15.5 | 165 | 316 | 52.2 | M | ||
| No | No | 74 | Nonsmoker | 0 | 1 | 67.9 | 26.7 | 11.1 | 4.1 | 106 | 247 | 42.9 | M | |
| Yes | No | 47 | Current | 0 | 1 | 65.1 | 20.4 | 5.4 | 3 | 52 | 314 | 16.6 | M | |
| No | No | 57 | Past | 0 | 1 | 81.6 | 30.7 | 9.1 | 4.1 | 102 | 377 | 27.1 | M | |
| No | No | 32 | Past | 1 | 1 | 63.4 | 22.2 | 13 | 4.6 | 67 | 321 | 20.9 | M | |
| Yes | Yes | 73 | Nonsmoker | 0 | 1 | 65.9 | 23 | 11.6 | 3.8 | 156 | 226 | 69 | M | |
| No | No | 49 | Current | 0 | 1 | 75.1 | 26.2 | 8.8 | 4.2 | 54 | 341 | 15.8 | M | |
| No | No | 35 | Current | 0 | 1 | 125.8 | 36.6 | 22.4 | 4.7 | 124 | 411 | 30.2 | M | |
| No | No | 26 | Past | 1 | 1 | 99.8 | 28.6 | 15.1 | 4.7 | 138 | 373 | 37 | M | |
| No | No | 70 | Nonsmoker | 0 | 1 | 69 | 25.3 | 9.5 | 4.5 | 75 | 283 | 26.5 | M | |
| No | No | 36 | Current | 0 | 1 | 92.6 | 28.1 | 11.4 | 4.2 | 110 | 325 | 33.8 | M | |
| No | No | 66 | Nonsmoker | 0 | 1 | 121.5 | 37.6 | 21.8 | 111 | 367 | 30.2 | M | ||
| No | No | 38 | Past | 1 | 1 | 84.1 | 28.8 | 9.1 | 5 | 129 | 448 | 28.8 | M | |
| No | No | 27 | Current | 1 | 1 | 90.5 | 28.8 | 36.9 | 93 | 389 | 23.9 | M | ||
| No | No | 60 | Nonsmoker | 1 | 1 | 75.1 | 24.4 | 20.9 | 4.4 | 106 | 368 | 28.8 | M | |
| No | No | 47 | Current | 0 | 1 | 54.7 | 18.7 | 0.6 | 4.2 | 180 | 449 | 40.1 | M | |
| Yes | Yes | 70 | Unknown | 0 | 1 | 62.6 | 20.6 | 15.2 | 4 | 173 | 274 | 63.1 | M | |
| No | No | 71 | Nonsmoker | 0 | 1 | 77.2 | 28.3 | 8.6 | 4.4 | 126 | 295 | 42.7 | M | |
| No | No | 56 | Current | 1 | 1 | 65.4 | 19.4 | 14 | 3.8 | 121 | 252 | 48 | M | |
| No | No | 42 | Current | 0 | 1 | 86.9 | 30.9 | 15.6 | 5 | 105 | 366 | 28.7 | M | |
| No | No | 65 | Current | 0 | 1 | 66.9 | 23.9 | 13.5 | 148 | 303 | 48.8 | M | ||
| No | No | 43 | Nonsmoker | 0 | 1 | 74.8 | 23.4 | 23.2 | 137 | 342 | 40.1 | M | ||
| No | No | 33 | Nonsmoker | 0 | 1 | 87.1 | 30.3 | 36 | 103 | 301 | 34.2 | M | ||
| … | … | … | … | … | … | … | … | … | … | … | … | … | … | … |
(plot/render-image
{:data (nu/dataset :nhanes)
:mapping {:x :tibc :y :hemoglobin :facet :sex}
:scales {:color {:range [[200 200 200] [0 0 0]]}}
:charts [(chart/bin2d {:bins 30})]
:facets {:columns 2}
:labels {:x "TIBC" :y "Hemoglobin"}}
{:width 900 :height 450})
38.14.5 Fig 14.5 Pie charts
Virginia death rates (1940) by age group as a pie per population group - bars stacked to the group’s whole (:position :normalize) in polar coordinates: panels share the angle scale, so each pie shows shares.
Source: Lattice Fig 14.5. Data: Death rates in Virginia (1940), R datasets package VADeaths (Molyneaux et al. 1947); licence: Part of R (GPL-2 | GPL-3).
(plot/render-image
{:data va-deaths
:mapping {:x :rate :color :age :facet :group}
:coord {:kind :polar}
:scales {:x {:axis false} :facet {:domain ["Urban Male" "Urban Female" "Rural Male" "Rural Female"]}}
:charts [(chart/bar {:position :normalize :width 1.0})]
:facets {:columns 2}
:labels {:x nil :y nil}}
{:width 800 :height 800})
source: notebooks/galleries/lattice.clj
























