Plots lines on the given scatter or line plot of the (x,y) points.
Equivalent to R's lines function, returns the modified chart object.
Options:
:series-label (default x expression)
Examples:
(use '(incanter core stats io datasets charts))
(def cars (to-matrix (get-dataset :cars)))
(def y (sel cars :cols 0))
(def x (sel cars :cols 1))
(def plot1 (scatter-plot x y :legend true))
(view plot1)
;; add regression line to scatter plot
(def lm1 (linear-model y x))
(add-lines plot1 x (:fitted lm1))
;; model the data without an intercept
(def lm2 (linear-model y x :intercept false))
(add-lines plot1 x (:fitted lm2))
;; Clojure's doto macro can be used to build a chart
(doto (histogram (sample-normal 1000) :density true)
(add-lines (range -3 3 0.05) (pdf-normal (range -3 3 0.05)))
view)
(with-data (get-dataset :iris)
(doto (xy-plot :Sepal.Width :Sepal.Length :legend true)
(add-lines :Petal.Width :Petal.Length)
view))
References:
http://www.jfree.org/jfreechart/api/javadoc/
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html
Comments top
No comments for add-lines. Log in to add a comment.