def setDrawer(self, *args):
if args:
# divide the arguments into qualifieds or unqualifieds
(qualifieds, unqualifieds) = \
hvutil.partition(operator.methodcaller('group', 'yAx'),
filter(operator.truth,
map(re.compile(r"^((?P<yAx>[^:]+):)?(?P<method>lines|points|both)$", re.I).match, args)))
# Make sure that every entry matched
if (len(qualifieds)+len(unqualifieds))!=len(args):
raise RuntimeError, "Invalid draw method(s) specified; use Lines, Points or Both"
# Depending in which one is the empty list we do things
# and we complain loudly + bitterly if they're both non-empty ...
if qualifieds and not unqualifieds:
for qual in qualifieds:
ax = qual.group('yAx')
if ax not in self.yAxis:
raise RuntimeError, "The current plot type has no panel for {0}".format( ax )
yIdx = self.yAxis.index( ax )
dm = qual.group('method').capitalize()
self.drawers[yIdx] = self.drawDict[ dm ]
self.drawMethod[yIdx] = dm
elif unqualifieds and not qualifieds:
# all unqualified. Only acceptable: 1 unqualified or nYAxis unqualifieds
if len(unqualifieds)!=len(self.yAxis) and len(unqualifieds)!=1:
raise RuntimeError, "Incorrect number of drawing methods supplied for plot type (either 1 or {0})".format(len(self.yAxis))
# if there's just one, replicate to len yAxis
methods = unqualifieds if len(unqualifieds)==len(self.yAxis) else [unqualifieds[0]] * len(self.yAxis)
for (idx, method) in enumerate(methods):
dm = method.group('method').capitalize()
self.drawers[idx] = self.drawDict[ dm ]
self.drawMethod[idx] = dm
else:
raise RuntimeError, "You cannot mix qualified axis drawing methods with unqualified ones"
return " ".join(map(":".join, zip(self.yAxis, self.drawMethod)))
# want to fix the scale of the axes?
# can give either:
# Scaling.auto_global, Scaling.auto_local or [<min>, <max>]
# There's no asserts being done - you'll find out at runtime if
# it's been set to something "the system" doesn't grok ...
评论列表
文章目录