(defn box-plot*
([x & options]
(let [opts (when options (apply assoc {} options))
data (:data opts)
_x (if (coll? x) (to-list x) ($ x data))
_group-by (when (:group-by opts)
(if (coll? (:group-by opts))
(to-list (:group-by opts))
($ (:group-by opts) data)))
x-groups (when _group-by
(map #($ :col-0 %)
(vals ($group-by :col-1 (conj-cols _x _group-by)))))
__x (if x-groups
(first x-groups)
_x)
main-title (or (:title opts) "")
x-label (or (:x-label opts) "")
y-label (or (:y-label opts) (str 'x))
series-label (or (:series-label opts) (str 'x))
category-label (or (:category-label opts) 0)
group-labels (:group-labels opts)
theme (or (:theme opts) :default)
legend? (true? (:legend opts))
dataset (DefaultBoxAndWhiskerCategoryDataset.)
chart (org.jfree.chart.ChartFactory/createBoxAndWhiskerChart
main-title
x-label
y-label
dataset
legend?)]
(do
(-> chart .getCategoryPlot .getRenderer (.setMaximumBarWidth 0.25))
(.add dataset __x
(if _group-by
(str series-label " (0)")
series-label)
category-label)
(when-not (empty? (rest x-groups))
(doseq [i (range 1 (count x-groups))]
(.add dataset
(nth x-groups i)
(str series-label " (" i ")") i)))
(set-theme chart theme)
chart))))
Used in 0 other vars
Comments top
No comments for box-plot*. Log in to add a comment.