Another common type of chart is a bar chart. These are good for comparing the sums or the counts of a few categories in the data.
We'll use the same dependencies in our project.clj
file as we did in the Creating scatter plots with Incanter recipe.
We'll use the following set of imports in our script or REPL:
(require '[incanter.core :as i] '[incanter.charts :as c] 'incanter.datasets)
For this recipe, we'll use a standard dataset of chick weights. This comes with Incanter, so it's simple to load.
(def chick-weight (incanter.datasets/get-dataset :chick-weight))
In this example, we'll chart the weight of the chicks by their diets.
We get the total weights for the chicks eating each diet with the
incanter.core/$rollup
function.(def chick-weight-bar (i/with-data (i/$order :Diet :asc (i/$rollup :sum :weight :Diet chick-weight)) (c/bar-chart (i/$map int :Diet) :weight :title...