Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAneesh Dogra <lionaneesh@gmail.com>2012-12-04 10:08:39 (GMT)
committer Aneesh Dogra <lionaneesh@gmail.com>2012-12-04 10:09:51 (GMT)
commit6039659ec69dd182b27a001502ae1ef2ab376eab (patch)
tree2729735cb2d96d430f179823bfd35da23b534b2e
parenta0179315545c30618ad58d1892baaeccb866877a (diff)
Fix division by 0 error, when provided with N..N range. N being any number.
Also fix #4297 locally.
-rw-r--r--plotlib.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/plotlib.py b/plotlib.py
index 483c512..74a4d17 100644
--- a/plotlib.py
+++ b/plotlib.py
@@ -158,7 +158,7 @@ class CustomPlot(_PlotBase):
self.maxy = max(float(y), self.maxy)
if self.minx == self.maxx:
- xYspace = 0.5
+ x_space = 0.5
else:
x_space = 0.02 * (self.maxx - self.minx)
self.minx -= x_space
@@ -214,16 +214,18 @@ class CustomPlot(_PlotBase):
# X axis
interval = len(val)/(NOL - 1)
self.plot_line((0.11, 0.89), (0.92, 0.89), "black")
- self.add_text((0.11 + min_x + F * 0, 0.93), format_float(min_x))
- plot_index = interval
-
- while plot_index <= len(val) - interval:
- self.add_text((0.11 + F * abs(x_coords[plot_index] - min_x) / \
- abs(max_x - min_x), 0.93), \
- format_float(x_coords[plot_index]))
- plot_index += interval
+ if max_x != min_x:
+ self.add_text((0.11 + min_x + F * 0, 0.93), format_float(min_x))
+ plot_index = interval
+ while plot_index <= len(val) - interval:
+ self.add_text((0.11 + F * abs(x_coords[plot_index] - min_x) / \
+ abs(max_x - min_x), 0.93), \
+ format_float(x_coords[plot_index]))
+ plot_index += interval
+ self.add_text((0.11 + F * 1, 0.93), format_float(max_x))
+ else:
+ self.add_text((0.5 , 0.93), format_float(min_x))
- self.add_text((0.11 + F * 1, 0.93), format_float(max_x))
self.add_text((0.50, 0.98), labelx)
# Y axis