Skip to content

Instantly share code, notes, and snippets.

@croach
Created August 14, 2011 22:10
Show Gist options
  • Save croach/1145372 to your computer and use it in GitHub Desktop.
Save croach/1145372 to your computer and use it in GitHub Desktop.
Scatter Plot w/ Normalized Data
(ns hooray-data.core
(:gen-class)
(:use (incanter core stats charts io))
(:use [incanter.processing :only (norm)]))
(def data (read-dataset
"https://raw.github.com/liebke/incanter/master/data/iris.dat"
:delim \space
:header true))
(defn normalize
"Normalizes a set of data"
[data]
(let [start (apply min data)
stop (apply max data)]
(map #(norm % start stop) data)))
(def plot (scatter-plot
(normalize (sel data :cols 0))
(normalize (sel data :cols 1))
:x-label "Sepal Length"
:y-label "Sepal Width"
:group-by (sel data :cols 4)))
(defn -main [& args]
(view plot))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment