Permalink
Browse files

Merge pull request #118 from nbeloglazov/master

Finish funciton plots strictly on max-range value.
  • Loading branch information...
2 parents a9f8d13 + 10f4bbc commit 2ca7f7497117c1e5cfb5534f364d61f9be9205f4 @alexott alexott committed Jan 3, 2013
Showing with 8 additions and 4 deletions.
  1. +8 −4 modules/incanter-charts/src/incanter/charts.clj
@@ -322,6 +322,10 @@
x
[x]))
+(defn- range-inclusive [start end step]
+ "Similar to range but adds end to result."
+ (concat (range start end step) [end]))
+
(defn add-histogram*
([chart x & options]
(let [opts (when options (apply assoc {} options))
@@ -645,7 +649,7 @@
(let [opts (when options (apply assoc {} options))
step-size (or (:step-size opts)
(float (/ (- max-range min-range) 500)))
- x (range min-range (+ step-size max-range) step-size)
+ x (range-inclusive min-range max-range step-size)
series-lab (or (:series-label opts)
(format "%s" 'function))]
(add-lines chart x (map function x) :series-label series-lab))))
@@ -713,7 +717,7 @@
(let [opts (when options (apply assoc {} options))
step-size (or (:step-size opts)
(float (/ (- max-range min-range) 500)))
- t (range min-range (+ step-size max-range) step-size)
+ t (range-inclusive min-range max-range step-size)
[x y] (apply map vector (map function t))
series-lab (or (:series-label opts)
(format "%s" 'function))]
@@ -2369,7 +2373,7 @@
([function min-range max-range & options]
(let [opts (when options (apply assoc {} options))
step-size (or (:step-size opts) (float (/ (- max-range min-range) 500)))
- _x (range min-range (+ step-size max-range) step-size)
+ _x (range-inclusive min-range max-range step-size)
title (or (:title opts) "")
x-lab (or (:x-label opts) (format "%s < x < %s" min-range max-range))
y-lab (or (:y-label opts) (str 'function))
@@ -2437,7 +2441,7 @@
([function min-range max-range & options]
(let [opts (when options (apply assoc {} options))
step-size (or (:step-size opts) (float (/ (- max-range min-range) 500)))
- _t (range min-range (+ step-size max-range) step-size)
+ _t (range-inclusive min-range max-range step-size)
[_x _y] (apply map vector (map function _t))
title (or (:title opts) "")
x-lab (or (:x-label opts) (format "%s < x < %s" (apply min _x) (apply max _x)))

0 comments on commit 2ca7f74

Please sign in to comment.