1.2.3-SNAPSHOT permalink Arrow_down_16x16

xy-plot*

incanter.charts

  • (xy-plot* x y create-plot & options)

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

(defn xy-plot*
  ([x y create-plot & options]
    (let [opts (when options (apply assoc {} options))
	  data (:data opts)
	  _x (if (coll? x) (to-list x) ($ x data))
	  _y (if (coll? y) (to-list y) ($ y data))
	  _group-by (when (:group-by opts) 
		      (if (coll? (:group-by opts)) 
			(to-list (:group-by opts))
			($ (:group-by opts) data)))
	  x-groups (when _group-by 
		     (map #($ :col-0 %) 
			  (vals ($group-by :col-1 (conj-cols _x _group-by)))))
	  y-groups (when _group-by 
		     (map #($ :col-0 %) 
			  (vals ($group-by :col-1 (conj-cols _y _group-by)))))
	  __x (if x-groups (first x-groups) _x)
           __y (if y-groups (first y-groups) _y)
	  main-title (or (:main-title opts) "")
	  x-lab (or (:x-label opts) (str 'x))
	  y-lab (or (:y-label opts) (str 'y))
	  series-lab (or (:series-label opts) 
			  (if x-groups 
			    (format "%s, %s (0)" 'x 'y) 
			    (format "%s, %s" 'x 'y)))
	  theme (or (:theme opts) :default)
	  legend? (true? (:legend opts))
	  data-series (XYSeries. series-lab)
	  dataset (XYSeriesCollection.)
	  chart (do
              (doseq [i (range (count __x))] 
		        (.add data-series (nth __x i)  (nth __y i)))
               (.addSeries dataset data-series)
                    (create-plot
                        main-title
                        x-lab
                        y-lab
                        dataset
                        legend?
                        true  ; tooltips
                        false))
           _ (when x-groups
                (doseq [i (range 1 (count x-groups))]
                  (add-lines chart (nth x-groups i)
                             (nth y-groups i)
                             :series-label (format "%s, %s (%s)" 'x 'y i))))]
      (set-theme chart theme)  
      chart)))
Vars in incanter.charts/xy-plot*: defn let
Used in 0 other vars

Comments top

No comments for xy-plot*. Log in to add a comment.