|
64 | 64 | ;; |
65 | 65 | ;; Let's start with a basic dataset and plot. |
66 | 66 |
|
67 | | -;; Assume we have some data. |
68 | | - |
69 | 67 | (def sample-data |
70 | 68 | (tc/dataset {:x [1 2 3 4 5] |
71 | 69 | :y [2 4 3 5 7]})) |
|
134 | 132 | ;; better way to teach Tufte's [data-ink ratio](https://infovis-wiki.net/wiki/Data-Ink_Ratio) principle than doing exactly |
135 | 133 | ;; what it asks us to avoid, by adding some chartjunk? |
136 | 134 |
|
137 | | -;; Here are a few ways we can do it. |
| 135 | +;; Here are three approaches, each with different tradeoffs. |
138 | 136 |
|
139 | | -;; ## Using the relevant substitution keys |
| 137 | +;; ## Approach 1: Using the relevant substitution keys |
140 | 138 |
|
141 | 139 | ;; Sometimes, what we need can be precisely specified in Tableplot. |
142 | 140 | ;; You may find the following in Tableplot's |
|
146 | 144 | ;; - [`:=yaxis-gridcolor`](https://scicloj.github.io/tableplot/tableplot_book.plotly_reference.html#yaxis-gridcolor) - The color for the y axis grid lines |
147 | 145 |
|
148 | 146 | ;; To use them, you can add a `base` before your plot layers, |
149 | | -;; and configure it with these keys: |
| 147 | +;; and configure it with these keys. We use `plotly/base` because its |
| 148 | +;; parameters flow to all subsequent layers, which is useful when |
| 149 | +;; composing multiple layers with shared settings. |
150 | 150 |
|
151 | 151 | (-> sample-data |
152 | 152 | (plotly/base {:=xaxis-gridcolor "green" |
|
170 | 170 |
|
171 | 171 | ;; ::: |
172 | 172 |
|
173 | | -;; ## Overriding a broader-scope key |
| 173 | +;; ## Approach 2: Overriding a broader-scope key |
174 | 174 |
|
175 | | -;; Sometimes, you will not find exactly what you need in Tableplot's |
176 | | -;; parameter system. Plotly.js itself will always be richer and more |
177 | | -;; flexible. |
| 175 | +;; What if the specific keys you need don't exist in Tableplot yet? |
| 176 | +;; |
| 177 | +;; Plotly.js itself will always be richer and more flexible than Tableplot's |
| 178 | +;; parameter system. |
178 | 179 |
|
179 | 180 | ;; Imagine that the above `:=xaxis-gridcolor` & `:=yaxis-gridcolor` would |
180 | 181 | ;; not be supported. |
|
183 | 184 | ;; [Styling and Coloring Axes and the Zero-Line](https://plotly.com/javascript/axes/#styling-and-coloring-axes-and-the-zero-line) |
184 | 185 | ;; in the Plotly.js docs, you will |
185 | 186 | ;; see that, under the `layout` part of the specification, |
186 | | -;; you can specificy `gridcolor` for each of the axes. |
| 187 | +;; you can specify `gridcolor` for each of the axes. |
187 | 188 |
|
188 | 189 | ;; In Tableplot, we can specify the whole layout using `:=layout`, and thus |
189 | 190 | ;; have anything we need in there. |
|
227 | 228 |
|
228 | 229 | ;; ::: |
229 | 230 |
|
230 | | -;; ## Direct Manipulation After `plotly/plot` |
| 231 | +;; ## Approach 3: Direct Manipulation After `plotly/plot` |
231 | 232 |
|
232 | | -;; Sometimes, you wish to work with Plotly.js high-level notions, |
233 | | -;; but in a more refined way, preserving most of what we have. |
| 233 | +;; The previous approaches work within Tableplot's API. But what if you need |
| 234 | +;; more surgical control — to use Plotly.js concepts while preserving most defaults? |
234 | 235 |
|
235 | | -;; Can we do it? |
| 236 | +;; Of course we can do that! |
236 | 237 |
|
237 | | -;; Of course, the answer has been was in front of us the whole time: |
| 238 | +;; Of course, the answer has been in front of us the whole time: |
238 | 239 | ;; [It's just data](https://www.youtube.com/watch?v=jlPaby7suOc&t=1000s). |
239 | 240 |
|
240 | 241 | ;; We do not need to use Tableplot's API for everything. |
|
0 commit comments