You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/data_visualization/tableplot_parameter_flow.clj
+27-23Lines changed: 27 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -29,10 +29,9 @@
29
29
;;
30
30
;; This tutorial is a brief intro to this feature.
31
31
32
+
;; ::: {.callout-tip collapse="true"}
32
33
;; ### Background: The Layered Grammar of Graphics
33
34
;;
34
-
;; 💡 *(can skip on first read)*
35
-
;;
36
35
;; Tableplot is inspired by the [**layered grammar of graphics**](https://vita.had.co.nz/papers/layered-grammar.html),
37
36
;; a framework for understanding and building statistical visualizations. Originally developed by
38
37
;; Leland Wilkinson and later refined by Hadley Wickham in ggplot2, the grammar views plots as
@@ -59,7 +58,9 @@
59
58
;; - [Demystifying stat_ layers in ggplot2](https://yjunechoe.github.io/posts/2020-09-26-demystifying-stat-layers-ggplot2/) - June Choe's exploration of how the grammar elegantly handles data transformations, with special focus on making the internals observable and extensible
60
59
;; - [Analyzing Data with Clojure (Kevin Lynagh, 2012)](https://www.youtube.com/watch?v=xyGggdg31mc) - An early Clojure attempt to handle the challenge of building a grammar of graphics
61
60
62
-
;; ## The Challenge: Customizing Grid Colors
61
+
;; :::
62
+
63
+
;; ## A toy challenge: Customizing Grid Colors
63
64
;;
64
65
;; Let's start with a basic dataset and plot.
65
66
@@ -69,8 +70,6 @@
69
70
(tc/dataset {:x [12345]
70
71
:y [24357]}))
71
72
72
-
sample-data
73
-
74
73
;; In this tutorial, we'll use Tableplot's [Plotly.js](https://plotly.com/javascript/) API,
75
74
;; which generates interactive Plotly.js visualizations. Tableplot also supports other backends
76
75
;; like Vega-Lite and an experimental transpilation API.
@@ -83,18 +82,8 @@ sample-data
83
82
(plotly/layer-point {:=mark-size20})
84
83
plotly/layer-line)
85
84
86
-
;; ### Goal
87
-
88
-
;; Assume that we now wish to colour the grid lines: vertical by green,
89
-
;; horizontal by red. After all, what would be a
90
-
;; better way to teach Tufte's [data-ink ratio](https://infovis-wiki.net/wiki/Data-Ink_Ratio) principle than doing exactly
91
-
;; what it asks us to avoid, by adding some chartjunk?
92
-
93
-
;; Here are a few ways we can do it.
94
-
85
+
;; ::: {.callout-tip collapse="true"}
95
86
;; ### A brief look inside
96
-
;;
97
-
;; 💡 *(can skip on first read)*
98
87
99
88
;; By default, when used in [Kindly](https://scicloj.github.io/kindly-noted/)-compatible
100
89
;; tools like [Clay](https://scicloj.github.io/clay/) and in Clojure Civitas posts,
@@ -136,6 +125,17 @@ sample-data
136
125
plotly/plot
137
126
kind/pprint)
138
127
128
+
;; :::
129
+
130
+
;; ### Goal
131
+
132
+
;; Assume that we now wish to colour the grid lines: vertical by green,
133
+
;; horizontal by red. After all, what would be a
134
+
;; better way to teach Tufte's [data-ink ratio](https://infovis-wiki.net/wiki/Data-Ink_Ratio) principle than doing exactly
135
+
;; what it asks us to avoid, by adding some chartjunk?
136
+
137
+
;; Here are a few ways we can do it.
138
+
139
139
;; ## Using the relevant substitution keys
140
140
141
141
;; Sometimes, what we need can be precisely specified in Tableplot.
@@ -154,9 +154,8 @@ sample-data
154
154
(plotly/layer-point {:=mark-size20})
155
155
plotly/layer-line)
156
156
157
+
;; ::: {.callout-tip collapse="true"}
157
158
;; ### A brief look inside
158
-
;;
159
-
;; 💡 *(can skip on first read)*
160
159
161
160
;; Let us see what actually has changed in the
162
161
;; resulting specification:
@@ -169,6 +168,8 @@ sample-data
169
168
plotly/plot
170
169
kind/pprint)
171
170
171
+
;; :::
172
+
172
173
;; ## Overriding a broader-scope key
173
174
174
175
;; Sometimes, you will not find exactly what you need in Tableplot's
@@ -198,13 +199,12 @@ sample-data
198
199
;; Notice that a few other details of the aesthetics have changed,
199
200
;; like the plot's background color.
200
201
201
-
;; That is what happens when we override the whole `:layout`.
202
+
;; That is what happens when we override the whole `:=layout`.
202
203
;; It is a powerful option, that you may or may not like, depending on
203
204
;; your use case.
204
205
206
+
;; ::: {.callout-tip collapse="true"}
205
207
;; ### A brief look inside
206
-
;;
207
-
;; 💡 *(can skip on first read)*
208
208
209
209
;; Let us see what happens:
210
210
@@ -225,6 +225,8 @@ sample-data
225
225
;; in our previous example, we actually went through affecting the
226
226
;; broad-scope key, `:=layout`.
227
227
228
+
;; :::
229
+
228
230
;; ## Direct Manipulation After `plotly/plot`
229
231
230
232
;; Sometimes, you wish to work with Plotly.js high-level notions,
@@ -236,6 +238,7 @@ sample-data
236
238
;; [It's just data](https://www.youtube.com/watch?v=jlPaby7suOc&t=1000s).
237
239
238
240
;; We do not need to use Tableplot's API for everything.
241
+
;;
239
242
;; After we call `plotly/plot`, we can process the actual Plotly.js
240
243
;; specification, as data.
241
244
@@ -246,9 +249,8 @@ sample-data
246
249
(assoc-in [:layout:xaxis:gridcolor] "green")
247
250
(assoc-in [:layout:yaxis:gridcolor] "red"))
248
251
252
+
;; ::: {.callout-tip collapse="true"}
249
253
;; ### A brief look inside
250
-
;;
251
-
;; 💡 *(can skip on first read)*
252
254
253
255
;; You already know what to expect here:
254
256
@@ -260,6 +262,8 @@ sample-data
260
262
(assoc-in [:layout:yaxis:gridcolor] "red")
261
263
kind/pprint)
262
264
265
+
;; :::
266
+
263
267
;; ## Summary
264
268
;;
265
269
;; Tableplot's parameter substitution system gives you three levels of control:
0 commit comments