Adds a xy-plot of the given function to the given chart, returning
a modified version of the chart.
Options:
:series-label (default x expression)
:step-size (default (/ (- max-range min-range) 500))
See also:
function-plot, view, save, add-function, add-points, add-lines
Examples:
(use '(incanter core stats charts))
;; plot the sine and cosine functions
(doto (function-plot sin (- Math/PI) Math/PI)
(add-function cos (- Math/PI) Math/PI)
view)
;; plot two normal pdf functions
(doto (function-plot pdf-normal -3 3 :legend true)
(add-function (fn [x] (pdf-normal x :mean 0.5 :sd 0.5)) -3 3)
view)
;; plot a user defined function and its derivative
(use '(incanter core charts optimize))
;; define the function, x^3 + 2x^2 + 2x + 3
(defn cubic [x] (+ (* x x x) (* 2 x x) (* 2 x) 3))
;; use the derivative function to get a function
;; that approximates its derivative
(def deriv-cubic (derivative cubic))
;; plot the cubic function and its derivative
(doto (function-plot cubic -10 10)
(add-function deriv-cubic -10 10)
view)
Comments top
No comments for add-function. Log in to add a comment.