11 Ranking
Bar charts and their variants β comparing quantities across categories.
(ns napkinsketch-book.ranking
(:require
;; Shared datasets for these docs
[napkinsketch-book.datasets :as data]
;; Kindly β notebook rendering protocol
[scicloj.kindly.v4.kind :as kind]
;; Napkinsketch β composable plotting
[scicloj.napkinsketch.api :as sk]))(def sales {:product [:widget :gadget :gizmo :doohickey]
:revenue [120 340 210 95]})Bar Chart
Count occurrences of a categorical column.
(-> data/iris
(sk/lay-bar :species))Colored Bar Chart
Grouped (dodged) bars β count by day, colored by smoking status.
(-> data/tips
(sk/lay-bar :day {:color :smoker}))Stacked Bar Chart
Same data, stacked instead of dodged.
(-> data/tips
(sk/lay-stacked-bar :day {:color :smoker}))Stacked Bar (Proportions)
100% stacked bars β shows proportions instead of counts.
(-> data/penguins
(sk/lay-stacked-bar-fill :island {:color :species}))Horizontal Bar Chart
Flip the bar chart for horizontal orientation.
(-> data/iris
(sk/lay-bar :species)
(sk/coord :flip))Horizontal Colored Bars
Colored bars, flipped.
(-> data/tips
(sk/lay-bar :day {:color :time})
(sk/coord :flip))Value Bar
Pre-computed y values (no counting).
(-> sales
(sk/lay-value-bar :product :revenue))Value Bar (Horizontal)
Flip for horizontal orientation.
(-> sales
(sk/lay-value-bar :product :revenue)
(sk/coord :flip))Lollipop
Stem + dot β a lighter alternative to bar charts.
(-> sales
(sk/lay-lollipop :product :revenue))Lollipop (Horizontal)
Flipped for horizontal orientation.
(-> sales
(sk/lay-lollipop :product :revenue)
(sk/coord :flip))Whatβs Next
- Change over Time β line charts, step functions, and stacked areas
- Configuration β control dimensions, palettes, and themes