Database Reference
In-Depth Information
Designing good, informative, and beautiful charts is dificult, and if you want to dive into that
topic, and there's a lot of good information out there. Anything by Edward Tufte ( http://
www.edwardtufte.com/tufte/ ) is an excellent place to start, and his book, The Visual
Display of Quantitative Information , is considered a classic in the ield of data visualization
design. To create charts and graphs, there are a number of options. There are a lot of
solutions for graphing. In the next chapter, we'll look at some solutions involving ClojureScript
( https://github.com/clojure/clojurescript ) and d3 ( http://d3js.org/ ) . We
also have R ( http://www.r-project.org/ ), especially with its ggplot2 library ( http://
ggplot2.org/ ), and Mathematica ( http://www.wolfram.com/mathematica/ ), which
we worked with in Chapter 8 , Working with Mathematica and R , both of which have strong
graphing libraries.
In this chapter, we'll focus on Incanter charts. They are built on the JFreeChart library
( http://www.jfree.org/jfreechart/ ), which provides a powerful set of functions to
graph data. In this chapter, we'll use them to create a variety of types of graphs. We'll also
look at how to save graphs as PNG images. We'll use principal component analysis (PCA) to
project multidimensional data down to two dimensions so that they can be graphed easily.
Finally, we'll create an interactive, dynamic graph.
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 ile:
(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))
 
Search WWH ::




Custom Search