1.2.3-SNAPSHOT permalink Arrow_down_16x16

function-plot

incanter.charts

  • (function-plot function min-range max-range & options)
Returns a xy-plot object of the given function over the range indicated
by the min-range and max-range arguments. Use the 'view' function to
display the chart, or the 'save' function to write it to a file.

Options:
:title (default 'Histogram') main title
:x-label (default x expression)
:y-label (default 'Frequency')
:legend (default false) prints legend
:series-label (default x expression)
:step-size (default (/ (- max-range min-range) 500))

See also:
view, save, add-points, add-lines


Examples:

(use '(incanter core stats charts))

(view (function-plot sin (- Math/PI) Math/PI))
(view (function-plot pdf-normal -3 3))

(defn cubic [x] (+ (* x x x) (* 2 x x) (* 2 x) 3))
(view (function-plot cubic -10 10))

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:2198 top

(defmacro function-plot
" Returns a xy-plot object of the given function over the range indicated
  by the min-range and max-range arguments. Use the 'view' function to
  display the chart, or the 'save' function to write it to a file.

  Options:
    :title (default 'Histogram') main title
    :x-label (default x expression)
    :y-label (default 'Frequency')
    :legend (default false) prints legend
    :series-label (default x expression)
    :step-size (default (/ (- max-range min-range) 500))

  See also:
    view, save, add-points, add-lines


  Examples:

    (use '(incanter core stats charts))

    (view (function-plot sin (- Math/PI) Math/PI))
    (view (function-plot pdf-normal -3 3))

    (defn cubic [x] (+ (* x x x) (* 2 x x) (* 2 x) 3))
    (view (function-plot cubic -10 10))

"
  ([function min-range max-range & options]
    `(let [opts# ~(when options (apply assoc {} options))
           group-by# (:group-by opts#) 
           main-title# (or (:title opts#) "")
           x-lab# (or (:x-label opts#) (format "%s < x < %s" '~min-range '~max-range))
           y-lab# (or (:y-label opts#) (str '~function))
           series-lab# (or (:series-label opts#) (format "%s" '~function))
	   args# (concat [~function ~min-range ~max-range] 
			 (apply concat (seq (apply assoc opts# 
						   [:group-by group-by# 
						    :main-title main-title# 
						    :x-label x-lab# 
						    :y-label y-lab# 
						    :series-label series-lab#]))))]
       (apply function-plot* args#))))
Vars in incanter.charts/function-plot: apply assoc defmacro when concat format let list or seq str vector
Used in 0 other vars

Comments top

No comments for function-plot. Log in to add a comment.