(defmacro heat-map
"
Examples:
(use '(incanter core charts))
(defn f [x y] (sin (sqrt (plus (sq x) (sq y)))))
(view (heat-map f -10 10 -15 15))
(view (heat-map f -10 10 -10 10 :color? false))
(defn f2 [x y] (plus (sq x) (sq y)))
(view (heat-map f2 -10 10 -10 10))
(view (heat-map f2 -10 10 -10 10 :color? false))
(use 'incanter.stats)
(defn f3 [x y] (pdf-normal (sqrt (plus (sq x) (sq y)))))
(view (heat-map f3 -3 3 -3 3 :x-label \"x1\" :y-label \"x2\" :z-label \"pdf\"))
(view (heat-map f3 -3 3 -3 3 :color? false))
(defn f4 [x y] (minus (sq x) (sq y)))
(view (heat-map f4 -10 10 -10 10))
(view (heat-map f4 -10 10 -10 10 :color? false))
(use '(incanter core stats charts))
(let [data [[0 5 1 2]
[0 10 1.9 1]
[15 0 0.5 1.5]
[18 10 4.5 2.1]]
diffusion (fn [x y]
(sum (map #(pdf-normal (euclidean-distance [x y] (take 2 %))
:mean (nth % 2) :sd (last %))
data)))]
(view (heat-map diffusion -5 20 -5 20)))
"
([function x-min x-max y-min y-max & options]
`(let [opts# ~(when options (apply assoc {} options))
x-lab# (or (:x-label opts#) (format "%s < x < %s" '~x-min '~x-max))
y-lab# (or (:y-label opts#) (format "%s < y < %s" '~y-min '~y-max))
z-lab# (or (:z-label opts#) (str '~function))
args# (concat [~function ~x-min ~x-max ~y-min ~y-max]
(apply concat (seq (apply assoc opts#
[:z-label z-lab#
:x-label x-lab#
:y-label y-lab#]))))]
(apply heat-map* args#))))
Used in 0 other vars
Comments top
No comments for heat-map. Log in to add a comment.