|
303 | 303 |
|
304 | 304 | ;;; well that doesn't work |
305 | 305 |
|
| 306 | + |
| 307 | + |
| 308 | + |
306 | 309 | ^:kind/vega-lite |
307 | | -{:data |
308 | | - {:url |
309 | | - "https://raw.githubusercontent.com/ttimbers/palmerpenguins/refs/heads/file-variants/inst/extdata/penguins.tsv", |
310 | | - :format {:type "tsv"}}, |
311 | | - :config {:facet {:spacing 0}, :view {}}, |
| 310 | +{:data {:values (tc/rows penguin-data :as-maps)} |
| 311 | + :config {:facet {:spacing 0} |
| 312 | + :view {}} |
312 | 313 | :facet |
313 | | - {:row {:field "species island", :type :nominal, :header {:labelAngle 0, :labelAlign "left"}}}, |
| 314 | + {:row {:field "species island" |
| 315 | + :type :nominal |
| 316 | + :header {:labelAngle 0 :labelAlign "left"}}} |
314 | 317 | :spec |
315 | | - { :height 50, |
| 318 | + {:height 50 |
316 | 319 | :width 800 |
317 | | - :resolve {:scale {:y "independent"}}, |
| 320 | + :resolve {:scale {:y "independent"}} |
318 | 321 | :layer |
319 | | - [{:mark {:type "point", :tooltip {:content :data}}, |
320 | | - :transform [{:calculate "random()", :as "jitter"}], |
| 322 | + [ |
| 323 | + ;; Violins |
| 324 | + {:mark {:type :area :orient :vertical} |
| 325 | + :transform [{:density "body_mass_g" |
| 326 | + :groupby ["species island"] |
| 327 | + :bandwidth 80 |
| 328 | + :extent [2200 6800]}] |
321 | 329 | :encoding |
322 | | - {:x {:field "body_mass_g", :type :quantitative, :scale {:zero false}}, |
| 330 | + {:color {:field "species island" :type :nominal :legend false} |
| 331 | + :x {:field "value" :type :quantitative :title "body_mass_g"} |
| 332 | + :y {:field "density" :type :quantitative :stack :center :axis false} |
| 333 | + :opacity {:value 0.7} |
| 334 | + } |
| 335 | + } |
323 | 336 |
|
324 | | - :y {:field "jitter", :type :quantitative, :axis false}, |
325 | | - :color {:field "species island", :type :nominal, :legend false}}, |
| 337 | + ;; Points |
| 338 | + {:mark {:type "point" :tooltip {:content :data}} |
| 339 | + :transform [{:calculate "random()" :as "jitter"}] |
| 340 | + :encoding |
| 341 | + {:x {:field "body_mass_g" :type :quantitative :scale {:zero false}} |
| 342 | + :y {:field "jitter" :type :quantitative :axis false} |
| 343 | + } |
326 | 344 | } |
| 345 | + |
| 346 | + ;; Box |
327 | 347 | {:mark |
328 | | - {:type :boxplot, |
329 | | - :tooltip {:content :data}, |
330 | | - :extent :min-max, |
331 | | - :box {:strokeWidth 1.5, :stroke "gray"}}, |
332 | | - :transform [{:calculate "random()", :as "jitter"}], |
| 348 | + {:type :boxplot |
| 349 | + :tooltip {:content :data} |
| 350 | + :extent :min-max |
| 351 | + :box {:strokeWidth 1.5 :stroke "gray"}} |
| 352 | + :transform [{:calculate "random()" :as "jitter"}] |
333 | 353 | :encoding |
334 | | - {:x {:field "body_mass_g", :type :quantitative, :scale {:zero false}}, |
| 354 | + {:x {:field "body_mass_g" |
| 355 | + :type :quantitative |
| 356 | + :scale {:zero false}} |
| 357 | + :fill {:value "none"} |
| 358 | + :stroke {:value "black"} |
| 359 | + } |
335 | 360 |
|
336 | | - :color {:field "species island", :type :nominal, :legend false}}, |
337 | 361 | } |
338 | | - {:mark {:type :area, :orient :vertical}, |
339 | | - :transform [{:density "body_mass_g" :groupby ["species island"]}], |
340 | | - :encoding |
341 | | - {:color {:field "species island", :type :nominal, :legend false}, |
342 | | - :x {:field "value", :type :quantitative, :title "body_mass_g", #_ :scale #_ {:zero false}}, |
343 | | - :y {:field "density", :type :quantitative, :stack :center, :axis false}, |
344 | | - }, |
345 | | - }], |
| 362 | + ] |
346 | 363 | }} |
347 | 364 |
|
348 | 365 |
|
|
0 commit comments