1.2.3-SNAPSHOT permalink Arrow_down_16x16
This is a general 'view' function. When given an Incanter matrix/dataset
or a Clojure numeric collection, it will display it in a Java Swing
JTable. When given an Incanter chart object, it will display it in a new
window. When given a URL string, it will open the location with the
platform's default web browser.

When viewing charts, a :width (default 500) and :height (default 400)
option can be provided.

When viewing an incanter.processing sketch, set the :exit-on-close option
to true (default is false) to kill the animation processes when you
close the window (this will also kill your REPL or Swank server),
otherwise those processing will continue to run in the background.



Examples:

(use '(incanter core stats datasets charts))

;; view matrices
(def rand-mat (matrix (sample-normal 100) 4))
(view rand-mat)

;; view numeric collections
(view [1 2 3 4 5])
(view (sample-normal 100))

;; view Incanter datasets
(view (get-dataset :iris))

;; convert dataset to matrix, changing Species names to numeric codes
(view (to-matrix (get-dataset :iris)))

;; convert dataset to matrix, changing Species names to dummy variables
(view (to-matrix (get-dataset :iris) :dummies true))

;; view a chart
(view (histogram (sample-normal 1000)) :width 700 :height 700)

;; view a URL
(view "http://incanter.org")

;; view a PNG file
(save (histogram (sample-normal 1000)) "/tmp/norm_hist.png")
(view "file:///tmp/norm_hist.png")


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/core.clj:2344 top

(defmulti view
  " This is a general 'view' function. When given an Incanter matrix/dataset
    or a Clojure numeric collection, it will display it in a Java Swing
    JTable. When given an Incanter chart object, it will display it in a new
    window. When given a URL string, it will open the location with the
    platform's default web browser.

    When viewing charts, a :width (default 500) and :height (default 400) 
    option can be provided.

    When viewing an incanter.processing sketch, set the :exit-on-close option
    to true (default is false) to kill the animation processes when you
    close the window (this will also kill your REPL or Swank server), 
    otherwise those processing will continue to run in the background.



    Examples:

      (use '(incanter core stats datasets charts))

      ;; view matrices
      (def rand-mat (matrix (sample-normal 100) 4))
      (view rand-mat)

      ;; view numeric collections
      (view [1 2 3 4 5])
      (view (sample-normal 100))

      ;; view Incanter datasets
      (view (get-dataset :iris))

      ;; convert dataset to matrix, changing Species names to numeric codes
      (view (to-matrix (get-dataset :iris)))

      ;; convert dataset to matrix, changing Species names to dummy variables
      (view (to-matrix (get-dataset :iris) :dummies true))

      ;; view a chart
      (view (histogram (sample-normal 1000)) :width 700 :height 700)

      ;; view a URL
      (view \"http://incanter.org\")

      ;; view a PNG file
      (save (histogram (sample-normal 1000)) \"/tmp/norm_hist.png\")
      (view \"file:///tmp/norm_hist.png\")


"
  (fn [obj & options] (cond
                        (and (not (matrix? obj))
                             (not (dataset? obj))
                             (not (map? obj))
                             (coll? obj))
                          ::coll
                        (.contains (str (type obj)) "processing.core.PApplet")
                          :sketch
                        :else
                        (type obj))))
Vars in incanter.core/view: and coll? cond defmulti fn map? not str type
Used in 0 other vars

Comments top

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