(defn histogram*
([x & options]
(let [opts (if options (apply assoc {} options) {})
data (:data opts)
_x (if (coll? x) (to-list x) ($ x data))
nbins (or (:nbins opts) 10)
theme (or (:theme opts) :default)
density? (true? (:density opts))
main-title (or (:title opts) "")
x-lab (or (:x-label opts) (str 'x))
y-lab (or (:y-label opts)
(if density? "Density" "Frequency"))
series-lab (or (:series-label opts) (str 'x))
legend? (true? (:legend opts))
dataset (HistogramDataset.)]
(do
(.addSeries dataset series-lab (double-array _x) nbins)
(when density? (.setType dataset org.jfree.data.statistics.HistogramType/SCALE_AREA_TO_1))
(let [chart (-> (org.jfree.chart.ChartFactory/createHistogram
main-title
x-lab
y-lab
dataset
org.jfree.chart.plot.PlotOrientation/VERTICAL
legend? ; no legend
true ; tooltips
false)
(set-theme theme))]
chart)))))
Used in 0 other vars
Comments top
No comments for histogram*. Log in to add a comment.