From bf09b9e71a4d325c72d126b920d87e09e6040380 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Sat, 31 Dec 2022 20:58:13 +0100 Subject: [PATCH 1/2] data_science.clj: vega-lite: fix tooltips Also making the use of "quantitative" vs :quantitative a bit more consistent, I hope. Signed-off-by: Stephan Renatus --- notebooks/data_science.clj | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/notebooks/data_science.clj b/notebooks/data_science.clj index 25a68fd..8ed154f 100644 --- a/notebooks/data_science.clj +++ b/notebooks/data_science.clj @@ -58,12 +58,12 @@ {:data {:values life-expectancy} :width 700 :height 500 - :mark {:type "point" - :tooltip {:field "Country"}} + :mark {:type :point} :encoding {:x {:field :gdp :type :quantitative} :y {:field :life-expectancy - :type :quantitative}}}) + :type :quantitative} + :tooltip {:field :country}}}) ;; Unsurprisingly, it seems that living in an extremely poor country ;; has negative consequences for life expectancy. On the other hand, @@ -122,29 +122,29 @@ {:data {:values expectancy-and-gini} :width 600 :height 1600 - :mark {:type "point" - :tooltip {:field :country}} + :mark {:type :point} :encoding {:x {:field :gini :type :quantitative} :y {:field :country :type :nominal - :sort "x"}}}) + :sort :x} + :tooltip {:field :country}}}) ;; And now to have a look at whether inequality and life expectancy ;; are correlated: (clerk/vl {:data {:values expectancy-and-gini} - :mark "rect" + :mark :rect :width 700 :height 500 :encoding {:x {:bin {:maxbins 25} :field :life-expectancy - :type "quantitative"} + :type :quantitative} :y {:bin {:maxbins 25} :field :gini - :type "quantitative"} - :color {:aggregate "count" :type "quantitative"}} - :config {:view {:stroke "transparent"}}}) + :type :quantitative} + :color {:aggregate :count :type :quantitative}} + :config {:view {:stroke :transparent}}}) ;; It seems like the mass of long lived countries are also in the ;; lower two thirds of the inequality distribution. A little filtering @@ -201,14 +201,14 @@ {:data {:values world-happiness+regression} :width 700 :height 500 - :layer [{:mark {:type "point" - :tooltip {:field :country}} + :layer [{:mark {:type :point} :encoding {:x {:field :score :type :quantitative :scale {:zero false}} :y {:field :gdp - :type :quantitative}}} - {:mark {:type "line" :color "#ccc"} + :type :quantitative} + :tooltip {:field :country}}} + {:mark {:type :line :color "#ccc"} :encoding {:x {:field :score :type :quantitative :scale {:zero false}} @@ -241,14 +241,14 @@ (take 20))} :width 700 :height 500 - :mark {:type "point" - :tooltip {:field :country}} + :mark {:type :point} :encoding {:x {:field :score :type :quantitative :scale {:zero false}} :y {:field :gini :type :quantitative - :scale {:zero false}}}}) + :scale {:zero false}} + :tooltip {:field :country}}}) ;; This does, at least at first glance, support the notion that the ;; happiest people — just like the longest lived ones — tend to From e666ec36c1bc59465b306c014e699014de6a06be Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Sat, 31 Dec 2022 20:58:44 +0100 Subject: [PATCH 2/2] data_science.clj: remove unused import Signed-off-by: Stephan Renatus --- notebooks/data_science.clj | 1 - 1 file changed, 1 deletion(-) diff --git a/notebooks/data_science.clj b/notebooks/data_science.clj index 8ed154f..93ee4a3 100644 --- a/notebooks/data_science.clj +++ b/notebooks/data_science.clj @@ -9,7 +9,6 @@ [meta-csv.core :as csv] [next.jdbc :as jdbc] [next.jdbc.result-set :as rs] - [next.jdbc.sql :as sql] [nextjournal.clerk :as clerk])) ;; # Exploring the world in data