Creating scatter plots with Incanter
One of the most common types of charts is a scatter plot. This helps us visualize the relationship between two numeric variables.
Getting ready
We'll need to list Incanter as a dependency in our Leiningen project.clj
file:
(defproject reports "0.1.0-SNAPSHOT" :dependencies [[org.clojure/clojure "1.6.0"] [incanter "1.5.5"]])
We'll also require several of Incanter's namespaces into our script or REPL:
(require '[incanter.core :as i] '[incanter.charts :as c] 'incanter.datasets)
Finally, we'll use the iris dataset, which we saw in several recipes in Chapter 9, Clustering, Classifying, and Working with Weka:
(def iris (incanter.datasets/get-dataset :iris))
How to do it...
For this recipe, we'll create a chart plotting the dimensions of the iris' petals:
- We'll create the chart, but hang on to the object created so that we can do things with the chart...