1.2.3-SNAPSHOT Arrow_down_16x16

stacked-area-chart

incanter.charts

  • (stacked-area-chart categories values & options)
Returns a JFreeChart object representing an stacked-area-chart of the given data.
Use the 'view' function to display the chart, or the 'save' function
to write it to a file.

Arguments:
categories -- a sequence of categories
values -- a sequence of numeric values

Options:
:title (default '') main title
:x-label (default 'Categories')
:y-label (default 'Value')
:series-label
:legend (default false) prints legend
:vertical (default true) the orientation of the plot
:group-by (default nil) -- a vector of values used to group the values into
series within each category.


See also:
view and save

Examples:


(use '(incanter core stats charts datasets))

(with-data (get-dataset :co2)
(view (stacked-area-chart :Type :uptake
:title "CO2 Uptake"
:group-by :Treatment
:x-label "Grass Types" :y-label "Uptake"
:legend true)))


(def data (get-dataset :airline-passengers))
(view (stacked-area-chart :year :passengers :group-by :month :legend true :data data))

(with-data (get-dataset :airline-passengers)
(view (stacked-area-chart :month :passengers :group-by :year :legend true)))


(def data (get-dataset :austres))
(view data)
(def plot (stacked-area-chart :year :population :group-by :quarter :legend true :data data))
(view plot)
(save plot "/tmp/austres_plot.png" :width 1000)
(view "file:///tmp/austres_plot.png")


(def seasons (mapcat identity (repeat 3 ["winter" "spring" "summer" "fall"])))
(def years (mapcat identity (repeat 4 [2007 2008 2009])))
(def values (sample-uniform 12 :integers true :max 100))
(view (stacked-area-chart years values :group-by seasons :legend true))

(view (stacked-area-chart ["a" "a" "b" "b" "c" "c" ] [10 20 30 10 40 20]
:legend true
:group-by ["I" "II" "I" "II" "I" "II"]))


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

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

  Arguments:
    categories -- a sequence of categories
    values -- a sequence of numeric values

  Options:
    :title (default '') main title
    :x-label (default 'Categories')
    :y-label (default 'Value')
    :series-label
    :legend (default false) prints legend
    :vertical (default true) the orientation of the plot
    :group-by (default nil) -- a vector of values used to group the values into
                               series within each category.


  See also:
    view and save

  Examples:


    (use '(incanter core stats charts datasets))

    (with-data (get-dataset :co2)
      (view (stacked-area-chart :Type :uptake
                       :title \"CO2 Uptake\"
                       :group-by :Treatment
                       :x-label \"Grass Types\" :y-label \"Uptake\"
                      :legend true)))


    (def data (get-dataset :airline-passengers))
    (view (stacked-area-chart :year :passengers :group-by :month :legend true :data data))

    (with-data  (get-dataset :airline-passengers)
      (view (stacked-area-chart :month :passengers :group-by :year :legend true)))


    (def data (get-dataset :austres))
    (view data)
    (def plot (stacked-area-chart :year :population :group-by :quarter :legend true :data data))
    (view plot)
    (save plot \"/tmp/austres_plot.png\" :width 1000)
    (view \"file:///tmp/austres_plot.png\")


    (def seasons (mapcat identity (repeat 3 [\"winter\" \"spring\" \"summer\" \"fall\"])))
    (def years (mapcat identity (repeat 4 [2007 2008 2009])))
    (def values (sample-uniform 12 :integers true :max 100))
    (view (stacked-area-chart years values :group-by seasons :legend true))

    (view (stacked-area-chart [\"a\" \"a\" \"b\" \"b\" \"c\" \"c\" ] [10 20 30 10 40 20]
                     :legend true
                     :group-by [\"I\" \"II\" \"I\" \"II\" \"I\" \"II\"]))


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

"
  ([categories values & options]
    `(let [opts# ~(when options (apply assoc {} options))
           group-by# (:group-by opts#) 
           main-title# (or (:title opts#) "")
           x-lab# (or (:x-label opts#) (str '~categories))
           y-lab# (or (:y-label opts#) (str '~values))
           series-lab# (or (:series-label opts#) (if group-by#
						   (format "%s (0)" '~categories) 
						   (format "%s" '~categories)))
	   args# (concat [~categories ~values] (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 stacked-area-chart* args#))))
Vars in incanter.charts/stacked-area-chart: apply assoc defmacro when concat format let list or seq str vector
Used in 0 other vars

Comments top

No comments for stacked-area-chart. Log in to add a comment.