Some Practical Clojure Examples
← prev | next →     Top-level ToC     /plotting.html     (printable version)

Use clj-xchart. Great docs and examples.

#!/usr/bin/env inlein

'{:dependencies [[org.clojure/clojure "1.8.0"]
                 [com.hypirion/clj-xchart "0.2.0"]]}

(require '[com.hypirion.clj-xchart :as chart])

(defn main
  []
  (chart/view
   (chart/xy-chart
    {"Data Set A" {:x [1 2 3 4 5]
                   :y [2 3 4 7 12]}}
    {:title "Plot Title"
     :x-axis {:title "horizontal-axis title"}
     :y-axis {:title "vertical-axis title"}})))
  
;;----
(main)

That code opens up a window with the plot image in it. One easy way to create a png file of the plot is to right-click in the image and save-as.

Close window — and hit ^C — to exit.