Book Image

Clojure Data Analysis Cookbook - Second Edition

By : Eric Richard Rochester
Book Image

Clojure Data Analysis Cookbook - Second Edition

By: Eric Richard Rochester

Overview of this book

Table of Contents (19 chapters)
Clojure Data Analysis Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Saving Incanter graphs to PNG


So far, we've been viewing the graphs we've created in a window on our computer. This is extremely handy, especially to quickly generate a graph and see what's in it. However, the chart would be more useful if we could save it. Then we could embed it in Word documents or web pages or print it so that we can hang it on the wall.

In this recipe, we'll save a graph of the iris data that we created in Creating scatter plots with Incanter.

Getting ready

We'll use the same dependencies in our project.clj file as we did in Creating scatter plots with Incanter, and this set of imports in our script or REPL:

(require '[incanter.core :as i]
         '[incanter.charts :as c])

We'll also use the chart object that we created in Creating scatter plots with Incanter, and we'll keep using the iris-petal-scatter variable name for it.

How to do it...

Since we already have the chart, saving it is simple. We just call incanter.core/save on it with the filename we want to save it to:

(i...