Cleaned up.
This commit is contained in:
parent
7cdb61dae2
commit
b070cc51ce
@ -1,6 +1,16 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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
|
||||||
|
<http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL>,
|
||||||
|
IcoGluco contains fonts from Noto Sans, as well as
|
||||||
|
green apple character from Vectors Market <https://www.flaticon.com/authors/vectors-market>,
|
||||||
|
licensed under Creative Commons BY 3.0, <http://creativecommons.org/licenses/by/3.0/>, and
|
||||||
|
syringe and pushpin characters from FreePik, <http://www.freepik.com>,
|
||||||
|
licensed under Creative Commons BY 3.0, <http://creativecommons.org/licenses/by/3.0/>
|
||||||
|
'''
|
||||||
|
|
||||||
__author__ = 'Timothy Allen'
|
__author__ = 'Timothy Allen'
|
||||||
__email__ = 'tim@treehouse.org.za'
|
__email__ = 'tim@treehouse.org.za'
|
||||||
@ -20,7 +30,6 @@ from matplotlib.collections import LineCollection
|
|||||||
from matplotlib.colors import ListedColormap, BoundaryNorm
|
from matplotlib.colors import ListedColormap, BoundaryNorm
|
||||||
from matplotlib import dates as mdates
|
from matplotlib import dates as mdates
|
||||||
from matplotlib import font_manager as fm
|
from matplotlib import font_manager as fm
|
||||||
from matplotlib import image
|
|
||||||
from matplotlib.patches import Circle, PathPatch
|
from matplotlib.patches import Circle, PathPatch
|
||||||
from matplotlib.path import Path
|
from matplotlib.path import Path
|
||||||
from matplotlib import ticker as mticker
|
from matplotlib import ticker as mticker
|
||||||
@ -430,7 +439,7 @@ def generate_plot(data, ax=None, transforms={}, args=[], **plot_args):
|
|||||||
symbol = ''
|
symbol = ''
|
||||||
symbol = '$'
|
symbol = '$'
|
||||||
for key in label:
|
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{SYRINGE} is a straight syringe (from FreePik),
|
||||||
\N{PUSHPIN} is a an angled syringe (from FreePik),
|
\N{PUSHPIN} is a an angled syringe (from FreePik),
|
||||||
\N{DAGGER} is unused,
|
\N{DAGGER} is unused,
|
||||||
@ -454,21 +463,6 @@ def generate_plot(data, ax=None, transforms={}, args=[], **plot_args):
|
|||||||
fontsize=10,
|
fontsize=10,
|
||||||
fontproperties=args.customfont,
|
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'] '''
|
''' Create a line coloured according to the list in transforms['color'] '''
|
||||||
if transform == 'boundaries' and 'color' in transforms:
|
if transform == 'boundaries' and 'color' in transforms:
|
||||||
@ -500,14 +494,6 @@ def generate_plot(data, ax=None, transforms={}, args=[], **plot_args):
|
|||||||
|
|
||||||
return ax
|
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):
|
def import_font(fontname):
|
||||||
basedir = os.path.dirname(os.path.abspath(__file__))
|
basedir = os.path.dirname(os.path.abspath(__file__))
|
||||||
fontdir = os.path.join(basedir, 'fonts')
|
fontdir = os.path.join(basedir, 'fonts')
|
||||||
|
Loading…
Reference in New Issue
Block a user