From b070cc51cefaaaeb55478690de5ae142979ad89a Mon Sep 17 00:00:00 2001 From: tim Date: Fri, 5 Jan 2018 08:47:24 +0200 Subject: [PATCH] Cleaned up. --- glucometer_graphs.py | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/glucometer_graphs.py b/glucometer_graphs.py index a615792..dff5b07 100755 --- a/glucometer_graphs.py +++ b/glucometer_graphs.py @@ -1,6 +1,16 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -'''Utility to convert data from a glucometer into charts.''' +''' Utility to convert data from a glucometer into charts. ''' + +''' Included are the Noto Sans and IcoGluco font sets. + Noto Sans is licensed under the SIL Open Font License version 1.1 + , + IcoGluco contains fonts from Noto Sans, as well as + green apple character from Vectors Market , + licensed under Creative Commons BY 3.0, , and + syringe and pushpin characters from FreePik, , + licensed under Creative Commons BY 3.0, +''' __author__ = 'Timothy Allen' __email__ = 'tim@treehouse.org.za' @@ -20,7 +30,6 @@ from matplotlib.collections import LineCollection from matplotlib.colors import ListedColormap, BoundaryNorm from matplotlib import dates as mdates from matplotlib import font_manager as fm -from matplotlib import image from matplotlib.patches import Circle, PathPatch from matplotlib.path import Path from matplotlib import ticker as mticker @@ -430,7 +439,7 @@ def generate_plot(data, ax=None, transforms={}, args=[], **plot_args): symbol = '' symbol = '$' for key in label: - ''' In the included IcoGluco font use for args.customfont, + ''' In the included IcoGluco font use for args.customfont, \N{SYRINGE} is a straight syringe (from FreePik), \N{PUSHPIN} is a an angled syringe (from FreePik), \N{DAGGER} is unused, @@ -454,21 +463,6 @@ def generate_plot(data, ax=None, transforms={}, args=[], **plot_args): fontsize=10, fontproperties=args.customfont, ) - ''' - if len(label) > 0: - if re.sub('F', '', label): - imagebox = OffsetImage(apple, axes=ax, zoom=.1, filternorm=None) - elif re.sub('I', '', label): - imagebox = OffsetImage(syringe, axes=ax, zoom=.1) - ab = AnnotationBbox( - imagebox, - xy=(x_pos, args.graph_max-y_offset), - frameon=False, - ) - ab.zorder = 25 - ax.add_artist(ab) - ''' - ''' Create a line coloured according to the list in transforms['color'] ''' if transform == 'boundaries' and 'color' in transforms: @@ -500,14 +494,6 @@ def generate_plot(data, ax=None, transforms={}, args=[], **plot_args): return ax -def import_icon(filename): - basedir = os.path.dirname(os.path.abspath(__file__)) - filepath = os.path.join(basedir, filename) - if not os.path.exists(filepath): - raise UserError("Image %s does not exist" % filepath) - icon = image.imread(filepath, format='png') - return icon - def import_font(fontname): basedir = os.path.dirname(os.path.abspath(__file__)) fontdir = os.path.join(basedir, 'fonts')