Adds a text annotation centered at the given coordinates.
Arguments:
chart -- the chart to annotate
x, y -- the coordinates to center the text
text -- the text to add
Examples:
;; PCA chart example
(use '(incanter core stats charts datasets))
;; load the iris dataset
(def iris (to-matrix (get-dataset :iris)))
;; run the pca
(def pca (principal-components (sel iris :cols (range 4))))
;; extract the first two principal components
(def pc1 (sel (:rotation pca) :cols 0))
(def pc2 (sel (:rotation pca) :cols 1))
;; project the first four dimension of the iris data onto the first
;; two principal components
(def x1 (mmult (sel iris :cols (range 4)) pc1))
(def x2 (mmult (sel iris :cols (range 4)) pc2))
;; now plot the transformed data, coloring each species a different color
(def plot (scatter-plot x1 x2
:group-by (sel iris :cols 4)
:x-label "PC1" :y-label "PC2" :title "Iris PCA"))
(view plot)
;; add some text annotations
(add-text plot -2.5 -6.5 "Setosa")
(add-text plot -5 -5.5 "Versicolor")
(add-text plot -8 -5.5 "Virginica")
Comments top
No comments for add-text. Log in to add a comment.