Skip to content

Instantly share code, notes, and snippets.

@liebke
Created April 20, 2009 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liebke/98560 to your computer and use it in GitHub Desktop.
Save liebke/98560 to your computer and use it in GitHub Desktop.
(use '(incanter core charts io))
;; create points to plot
(def x1 (range 0.1 5 0.1))
;; highlight a couple different sets of critical points
(def crit-pts1 [0.5 2 3])
(def crit-pts2 [0.25 2.5 3.5])
;; define a reciprocal function
(defn reciprocal [x] (div 1 x))
;; create a xy-plot using :title :series-label, and :legend options
;; you can also set the labels of the x and y axes using :x-label and :y-label options
(doto (xy-plot x1 (reciprocal x1)
:title "New Title"
:series-label "1/x"
:legend true)
view
(add-points crit-pts1 (reciprocal crit-pts1) :series-label "critical pts 1")
(add-points crit-pts2 (reciprocal crit-pts2) :series-label "critical pts 2")
clear-background
(set-x-label "x")
(set-y-label "y")
(save "/tmp/sample_plot.png"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment