1.2.3-SNAPSHOT Arrow_down_16x16

sliders*

incanter.charts

  • (sliders* f [& slider-values])
  • (sliders* f [& slider-values] [& slider-labels])
sliders*

Examples:
(use '(incanter core stats charts))

(let [x (range -3 3 0.1)]
(do
(def pdf-chart (xy-plot x (pdf-normal x :mean -3 :sd 0.1)))
(view pdf-chart)
(sliders* #(set-data pdf-chart [x (pdf-normal x :mean %1 :sd %2)])
[(range -3 3 0.1) (range 0.1 10 0.1)]
["mean" "sd"])))

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/charts.clj:2830 top

(defn sliders*
"sliders*

  Examples:
  (use '(incanter core stats charts))

  (let [x (range -3 3 0.1)] 
    (do
      (def pdf-chart (xy-plot x (pdf-normal x :mean -3 :sd 0.1)))
      (view pdf-chart)
      (sliders* #(set-data pdf-chart [x (pdf-normal x :mean %1 :sd %2)]) 
	       [(range -3 3 0.1) (range 0.1 10 0.1)] 
               [\"mean\" \"sd\"])))

"
  ([f [& slider-values]]
     (sliders* f (apply vector slider-values) [nil]))
  ([f [& slider-values] [& slider-labels]]
     (let [init-values (map first slider-values)
	   refs (map ref init-values)
	   slider-fns (map #(fn [v] 
			      (do 
				(dosync (ref-set (nth refs %) v)) 
				(apply f (map deref refs))))
			   (range (count refs)))
	   _ ((first slider-fns) (first init-values))]
       (if slider-labels 
	 (map slider slider-fns slider-values slider-labels)
	 (map slider slider-fns slider-values)))))
Vars in incanter.charts/sliders*: apply defn let map vector
Used in 0 other vars

Comments top

No comments for sliders*. Log in to add a comment.