From 5394bcee7cfc69da7c8c4332bdd5c3aa0cee17b2 Mon Sep 17 00:00:00 2001 From: tim Date: Wed, 3 Jan 2018 12:12:30 +0200 Subject: [PATCH] Fix labels with different units. --- glucometer_graphs.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/glucometer_graphs.py b/glucometer_graphs.py index b0bea12..b8c700b 100755 --- a/glucometer_graphs.py +++ b/glucometer_graphs.py @@ -6,10 +6,8 @@ __author__ = 'Timothy Allen' __email__ = 'tim@treehouse.org.za' __license__ = 'MIT' -# TODO: comments -- unicode -# TODO: prettify +# TODO: comments -- unicode/images/np.array # TODO: weekly graph with each day's figures as a different-coloured line -# TODO: verify either set of units (mmol/L,mg/dl) works with the data import argparse import csv @@ -419,13 +417,18 @@ def generate_plot(data, ax=None, transforms={}, args=[], **plot_args): # XXX At present, backend_pdf does not parse unicode correctly, and all recent # unicode chacters that lack proper glyph names are massed together and printed # as the same character + if args.units == UNIT_MMOLL: + y_offset = 6 + else: + y_offset = convert_glucose_unit(6, UNIT_MMOLL) + if transform == 'label' and transforms[transform] is True: - for a, b, label in zip(x, y, z): + for x_pos, y_pos, label in zip(x, y, z): if len(label) > 0: #print(label) ax.annotate( label, - xy=(a, args.graph_max-6), + xy=(x_pos, args.graph_max-y_offset), rotation=45, zorder=25, )