Fix labels with different units.
This commit is contained in:
parent
7087b5299a
commit
5394bcee7c
@ -6,10 +6,8 @@ __author__ = 'Timothy Allen'
|
|||||||
__email__ = 'tim@treehouse.org.za'
|
__email__ = 'tim@treehouse.org.za'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
|
|
||||||
# TODO: comments -- unicode
|
# TODO: comments -- unicode/images/np.array
|
||||||
# TODO: prettify
|
|
||||||
# TODO: weekly graph with each day's figures as a different-coloured line
|
# 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 argparse
|
||||||
import csv
|
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
|
# 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
|
# unicode chacters that lack proper glyph names are massed together and printed
|
||||||
# as the same character
|
# 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:
|
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:
|
if len(label) > 0:
|
||||||
#print(label)
|
#print(label)
|
||||||
ax.annotate(
|
ax.annotate(
|
||||||
label,
|
label,
|
||||||
xy=(a, args.graph_max-6),
|
xy=(x_pos, args.graph_max-y_offset),
|
||||||
rotation=45,
|
rotation=45,
|
||||||
zorder=25,
|
zorder=25,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user