346346(def annotation-marks
347347 " Marks that are annotations rather than data layers.
348348 'rule' is the traditional name for a reference line in plotting libraries."
349- #{:rule-h :rule-v :band-h })
349+ #{:rule-h :rule-v :band-h :band-v })
350350
351351(defn lay
352352 " Apply one or more layers to the base views. Each layer adds a mark, stat,
@@ -2289,9 +2289,11 @@ tips
22892289; ; Cross all columns with themselves; `resolve-view` infers histogram
22902290; ; for diagonal cells and scatter for off-diagonal:
22912291
2292+ ; ; :::{.column-screen-inset-right}
22922293(-> (view iris (cross iris-quantities iris-quantities))
22932294 (lay {:color :species })
22942295 plot)
2296+ ; ; :::
22952297
22962298; ; This is useful when diagonal and off-diagonal cells need different
22972299; ; aesthetics. Here, scatters are colored by species while the
@@ -2576,13 +2578,18 @@ tips
25762578 " Horizontal reference band between y1 and y2."
25772579 [y1 y2] {:mark :band-h :y1 y1 :y2 y2})
25782580
2581+ (defn vband
2582+ " Vertical reference band between x1 and x2."
2583+ [x1 x2] {:mark :band-v :x1 x1 :x2 x2})
2584+
25792585; ; ### 🧪 Annotation Specs
25802586; ;
25812587; ; Each annotation constructor returns a plain map:
25822588
25832589[(hline 3.0 )
25842590 (vline 6.0 )
2585- (hband 2.5 3.5 )]
2591+ (hband 2.5 3.5 )
2592+ (vband 5.5 6.5 )]
25862593
25872594; ; ### ⚙️ `render-annotation` methods
25882595
@@ -2616,6 +2623,14 @@ tips
26162623 :width (Math/abs (- x2 x1)) :height (Math/abs (- y2 y1))
26172624 :fill (:annotation-stroke cfg) :opacity (:band-opacity cfg)}]))
26182625
2626+ (defmethod render-annotation :band-v [ann {:keys [coord-fn y-domain cfg]}]
2627+ (let [cfg (or cfg defaults )
2628+ [x1 y1] (coord-fn (:x1 ann) (first y-domain))
2629+ [x2 y2] (coord-fn (:x2 ann) (second y-domain))]
2630+ [:rect {:x (min x1 x2) :y (min y1 y2)
2631+ :width (Math/abs (- x2 x1)) :height (Math/abs (- y2 y1))
2632+ :fill (:annotation-stroke cfg) :opacity (:band-opacity cfg)}]))
2633+
26192634; ; ### ⚙️ `render-mark` `:text`
26202635
26212636(defmethod render-mark :text [_ stat ctx]
@@ -2636,7 +2651,8 @@ tips
26362651 (lay (point {:color :species })
26372652 (hline 3.0 )
26382653 (hband 2.5 3.5 )
2639- (vline 6.0 ))
2654+ (vline 6.0 )
2655+ (vband 5.5 6.5 ))
26402656 plot)
26412657
26422658; ; ### 🧪 Text Labels at Group Means
@@ -2809,9 +2825,11 @@ tips
28092825; ;
28102826; ; Brush in one panel highlights the same rows across all panels:
28112827
2828+ ; ; :::{.column-screen-inset-right}
28122829(-> (view iris (cross iris-quantities iris-quantities))
28132830 (lay {:color :species })
28142831 (plot {:brush true }))
2832+ ; ; ::
28152833
28162834; ; ### 🧪 Brushable Facets
28172835; ;
0 commit comments