1.2.3-SNAPSHOT permalink Arrow_down_16x16

histogram

incanter.charts

  • (histogram x & options)
Returns a JFreeChart object representing the histogram of the given data.
Use the 'view' function to display the chart, or the 'save' function
to write it to a file.

Options:
:nbins (default 10) number of bins
:density (default false) if false, plots frequency, otherwise density
:title (default 'Histogram') main title
:x-label (default x expression)
:y-label (default 'Frequency')
:legend (default false) prints legend
:series-label (default x expression)


See also:
view, save, add-histogram

Examples:

(use '(incanter core charts stats))
(view (histogram (sample-normal 1000)))

# plot a density histogram
(def hist (histogram (sample-normal 1000) :density true))
(view hist)

# add a normal density line to the plot
(def x (range -4 4 0.01))
(add-lines hist x (pdf-normal x))

# plot some gamma data
(def gam-hist (histogram (sample-gamma 1000) :density true :nbins 30))
(view gam-hist)
(def x (range 0 8 0.01))
(add-lines gam-hist x (pdf-gamma x))

(use 'incanter.datasets)
(def iris (get-dataset :iris))
(view (histogram :Sepal.Width :data iris))

(with-data (get-dataset :iris)
(view (histogram :Petal.Length)))



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

(defmacro histogram
" Returns a JFreeChart object representing the histogram of the given data.
  Use the 'view' function to display the chart, or the 'save' function
  to write it to a file.

  Options:
    :nbins (default 10) number of bins
    :density (default false) if false, plots frequency, otherwise density
    :title (default 'Histogram') main title
    :x-label (default x expression)
    :y-label (default 'Frequency')
    :legend (default false) prints legend
    :series-label (default x expression)


  See also:
    view, save, add-histogram

  Examples:

    (use '(incanter core charts stats))
    (view (histogram (sample-normal 1000)))

    # plot a density histogram
    (def hist (histogram (sample-normal 1000) :density true))
    (view hist)

    # add a normal density line to the plot
    (def x (range -4 4 0.01))
    (add-lines hist x (pdf-normal x))

    # plot some gamma data
    (def gam-hist (histogram (sample-gamma 1000) :density true :nbins 30))
    (view gam-hist)
    (def x (range 0 8 0.01))
    (add-lines gam-hist x (pdf-gamma x))

    (use 'incanter.datasets)
    (def iris (get-dataset :iris))
    (view (histogram :Sepal.Width :data iris))

    (with-data (get-dataset :iris)
      (view (histogram :Petal.Length)))



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

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

Comments top

No comments for histogram. Log in to add a comment.