Skip to content

Commit 0999b4c

Browse files
author
Mike Travers
committed
iris dataset working, box-dot-plot working
1 parent 1e76a7e commit 0999b4c

1 file changed

Lines changed: 40 additions & 16 deletions

File tree

src/data_visualization/violin.clj

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,28 @@
144144

145145
;;; # Here's a more scientific example
146146

147-
(def iris
148-
(json/read-str (slurp "https://storage.googleapis.com/kagglesdsdata/datasets/20079/26025/iris.json?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=gcp-kaggle-com%40kaggle-161607.iam.gserviceaccount.com%2F20251129%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20251129T050349Z&X-Goog-Expires=259200&X-Goog-SignedHeaders=host&X-Goog-Signature=a076da9c0375641bed362393229356cd341ab694a356bbbadb6678f654ef58880b12de60a307cff229fc845e66a05acc14621bc4a6a022fc6419e0431327bc9b8105ca66e8289bd4b030825dfb5e0aaa7b0824bb9ebe9ed087c23329fb8a9259c86d0bccfdfe4da1f4d7ae84a91e14dc0df16aa011afecaa2daa1a96d83efc170e2d50758690b22e9b1fb289a476786d15f756e84724706c5581389462938de2a7d6d7ec38e20a7d7edc9b143ddef286e462f07c7827900a9e2130ca41cf21ce7da1e540d599d6bec333a0eae26af1532bf2ba745fd07e197226fb75795b1655aab3f62d097fa9be56a907e8c98601deb5c6c880e5ccc00617752ea92518f945")))
147+
(def iris-url "https://gist.githubusercontent.com/curran/a08a1080b88344b0c8a7/raw/0e7a9b0a5d22642a06d3d5b9bcbad9890c8ee534/iris.csv")
149148

150149
^:kind/vega-lite
151-
(violin-plot {:values iris} "petalWidth" "species" 0 4)
150+
(violin-plot {:url iris-url
151+
:format "csv"}
152+
"petal_width" "species"
153+
0 4)
154+
155+
^:kind/vega-lite
156+
{:mark {:type "boxplot"}
157+
:data {:url iris-url
158+
:format "csv"}
159+
:encoding
160+
{"x" {:field "petal_width"
161+
:type "quantitative"}
162+
"y" {:field "species"
163+
:type "nominal"}
164+
"color" {:field "species" :type "nominal" :legend false}
165+
}
166+
:width 800
167+
}
168+
152169

153170
^:kind/vega-lite
154171
(violin-plot {:url penguin-data-url
@@ -208,13 +225,16 @@
208225
{
209226
;; Data is in common
210227
:data data
211-
228+
:config {:facet {:spacing 0}
229+
:view {:stroke nil}}
212230
:facet
213231
{:row {:field group-field
214232
:type "nominal"
215-
:spacing 0 ;??? not working
216-
:header {:labelAngle 0 :labelAlign "left"}
217-
}}
233+
:header {:labelAngle 0
234+
:labelAlign "left"
235+
}
236+
}
237+
}
218238

219239
:spec
220240
{
@@ -238,22 +258,26 @@
238258
}}
239259

240260
;; box layer
241-
;; TODO turn off outliers, widen box
242-
{:mark {:type "boxplot" :outliers false}
261+
;; TODO widen box
262+
{:mark {:type "boxplot"
263+
:outliers false} ;turn off outlier points since we draw all points
243264
:encoding
244265
{:color {:field group-field :type "nominal" :legend false}
245266
}}]
246-
:width 800
267+
:width 800
247268
}
248269

249270
})
250271

272+
^:kind/vega-lite
273+
(box-dot-plot {:url penguin-data-url
274+
:format {:type "tsv"}}
275+
"flipper_length_mm" "species island"
276+
150 250)
251277

278+
;;; Let's try that for the movies
252279

253280
^:kind/vega-lite
254-
(box-dot-plot {:url penguin-data-url
255-
:format {:type "tsv"}
256-
}
257-
"flipper_length_mm" "species island"
258-
150 250
259-
)
281+
(box-dot-plot {:values movie-data}
282+
"US Gross" "Major Genre"
283+
0 500000000)

0 commit comments

Comments
 (0)