changeset 9:e2807c99e107

Fix battery charge scale to 0-100.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 11 Sep 2017 16:49:00 +0930
parents 22d31cee19b1
children 70cc1e874157
files agl.py
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/agl.py	Mon Sep 11 16:48:36 2017 +0930
+++ b/agl.py	Mon Sep 11 16:49:00 2017 +0930
@@ -210,10 +210,19 @@
         ydata = ary[:,idx + 1]
         if cols[idx] in convs:
             ydata = convs[cols[idx]](ydata)
+
+        if cols[idx] in scale_limits:
+            scale_min = scale_limits[cols[idx]][0]
+            scale_max = scale_limits[cols[idx]][1]
+        else:
+            scale_min = None
+            scale_max = None
+
         if units[cols[idx]] == yaxisunits1:
-            ax1lines.append([xdata, ydata, names[cols[idx]], colourlist[colouridx]])
+            ax = ax1lines
         else:
-            ax2lines.append([xdata, ydata, names[cols[idx]], colourlist[colouridx]])
+            ax = ax2lines
+        ax.append([xdata, ydata, names[cols[idx]], colourlist[colouridx], scale_min, scale_max])
         colouridx += 1
 
     if fname == None:
@@ -227,7 +236,9 @@
     ax1.set_ylabel(yaxisunits1)
 
     for line in ax1lines:
-        ax1.plot(line[0], line[1], label = line[2])
+        ax1.plot(line[0], line[1], label = line[2], color = line[3])
+        if line[4] != None and line[5] != None:
+            ax1.set_ylim((line[4], line[5]))
 
     ax1.legend(loc = 'upper left')
 
@@ -237,6 +248,8 @@
 
         for line in ax2lines:
             ax2.plot(line[0], line[1], label = line[2], color = line[3])
+            if line[4] != None and line[5] != None:
+                ax2.set_ylim(bottom = line[4], top = line[5])
         ax2.legend(loc = 'upper right')
 
     ndays = int(max(1, round(((end - start).total_seconds()) / 86400)))