# HG changeset patch # User Daniel O'Connor # Date 1505114340 -34200 # Node ID e2807c99e107b313a1d368a897c1c112c9599694 # Parent 22d31cee19b1e9f3cf6e0f1d99a8c900b175f054 Fix battery charge scale to 0-100. diff -r 22d31cee19b1 -r e2807c99e107 agl.py --- 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)))