1.2.3-SNAPSHOT permalink Arrow_down_16x16

box-plot

incanter.charts

  • (box-plot x & options)
Returns a JFreeChart object representing a box-plot of the given data.
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)
:group-by (default nil) -- a vector of values used to group the x values into series.

See also:
view and save

Examples:

(use '(incanter core stats charts))
(def gamma-box-plot (box-plot (sample-gamma 1000 :shape 1 :rate 2)
:title "Gamma Boxplot"
:legend true))
(view gamma-box-plot)
(add-box-plot gamma-box-plot (sample-gamma 1000 :shape 2 :rate 2))
(add-box-plot gamma-box-plot (sample-gamma 1000 :shape 3 :rate 2))

;; use the group-by options
(use '(incanter core stats datasets charts))
(with-data (get-dataset :iris)
(view (box-plot :Petal.Length :group-by :Species :legend true))
(view (box-plot :Petal.Width :group-by :Species :legend true))
(view (box-plot :Sepal.Length :group-by :Species :legend true))
(view (box-plot :Sepal.Width :group-by :Species :legend true)))

;; see INCANTER_HOME/examples/probability_plots.clj for more examples of plots

References:
http://www.jfree.org/jfreechart/api/javadoc/
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

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

(defmacro box-plot
" Returns a JFreeChart object representing a box-plot of the given data.
  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)
    :group-by (default nil) -- a vector of values used to group the x values into series.

  See also:
    view and save

  Examples:

    (use '(incanter core stats charts))
    (def gamma-box-plot (box-plot (sample-gamma 1000 :shape 1 :rate 2)
                          :title \"Gamma Boxplot\"
                          :legend true))
    (view gamma-box-plot)
    (add-box-plot gamma-box-plot (sample-gamma 1000 :shape 2 :rate 2))
    (add-box-plot gamma-box-plot (sample-gamma 1000 :shape 3 :rate 2))

    ;; use the group-by options
    (use '(incanter core stats datasets charts))
    (with-data (get-dataset :iris)
      (view (box-plot :Petal.Length :group-by :Species :legend true))
      (view (box-plot :Petal.Width :group-by :Species :legend true))
      (view (box-plot :Sepal.Length :group-by :Species :legend true))
      (view (box-plot :Sepal.Width :group-by :Species :legend true)))

    ;; see INCANTER_HOME/examples/probability_plots.clj for more examples of plots

  References:
    http://www.jfree.org/jfreechart/api/javadoc/
    http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

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

Comments top

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