def doit(config): fontparams = {} if config.pangofamily is not None: fontparams['family'] = config.pangofamily if config.pangosize is not None: fontparams['size'] = config.pangosize if len(fontparams): ompango.setFont(**fontparams) ompango.setBuiltinSubsuperRise(config.subsuperrise) # Plot bounds and tick marks are drawn in the "muted" color since you want # them to be less prominent than the data. However, when drawing a map, # which fills the plot field, the tick marks should be made more prominent # since they can easily get lost against the image. We achieve this by # redefining "muted". config.omstyle.colors.muted = config.omstyle.colors.foreground p = plot(config) if config.out is None: p.show(style=config.omstyle) else: p.save(config.out, style=config.omstyle, dims=config.dims, margins=config.margin)
def doit (config): fontparams = {} if config.pangofamily is not None: fontparams['family'] = config.pangofamily if config.pangosize is not None: fontparams['size'] = config.pangosize if len (fontparams): ompango.setFont (**fontparams) ompango.setBuiltinSubsuperRise (config.subsuperrise) # Plot bounds and tick marks are drawn in the "muted" color since you want # them to be less prominent than the data. However, when drawing a map, # which fills the plot field, the tick marks should be made more prominent # since they can easily get lost against the image. We achieve this by # redefining "muted". config.omstyle.colors.muted = config.omstyle.colors.foreground p = plot (config) if config.out is None: p.show (style=config.omstyle) else: p.save (config.out, style=config.omstyle, dims=config.dims, margins=config.margin)
def doit (driver, args): # Load up the driver code try: text = open (driver).read () except Exception as e: cli.die ('cannot read driver file "%s": %s', driver, e) try: code = compile (text, driver, 'exec') except Exception as e: if 'OMEGAFIG_BACKTRACE' in os.environ: raise cli.die ('cannot compile driver file "%s": %s', driver, e) ns = {'__file__': driver, '__name__': '__omegafig__'} try: exec (code, ns) except Exception as e: if 'OMEGAFIG_BACKTRACE' in os.environ: raise cli.die ('cannot execute driver file "%s": %s', driver, e) pfunc = ns.get ('plot') if pfunc is None: cli.die ('driver file "%s" does not provide a function called "plot"', driver) if not callable (pfunc): cli.die ('driver file "%s" provides something called "plot", but it\'s ' 'not a function', driver) # Deal with args try: code = pfunc.__code__ except AttributeError: code = pfunc.func_code nargs = code.co_argcount argnames = code.co_varnames keywords = [] nonkeywords = [] for arg in args: if '=' in arg: keywords.append (arg) else: nonkeywords.append (arg) if len (nonkeywords) != nargs: cli.die ('expected %d non-keyword arguments to driver, but got %d', nargs, len (nonkeywords)) config = Config () defaults = ns.get ('figdefaults') if defaults is not None: for key in defaults: setattr (config, key, defaults[key]) config.parse (keywords) # Set up omegaplot globals as appropriate if config.pango: try: import omega.pango_g3 as ompango except ImportError: import omega.pango_g2 as ompango fontparams = {} if config.pangofamily is not None: fontparams['family'] = config.pangofamily if config.pangosize is not None: fontparams['size'] = config.pangosize if len (fontparams): ompango.setFont (**fontparams) # Execute. p = pfunc (*nonkeywords) if config.out is None: p.show (style=config.omstyle) else: p.save (config.out, style=config.omstyle, dims=config.dims, margins=config.margin)
def doit(driver, args): # Load up the driver code try: text = open(driver).read() except Exception as e: cli.die('cannot read driver file "%s": %s', driver, e) try: code = compile(text, driver, 'exec') except Exception as e: if 'OMEGAFIG_BACKTRACE' in os.environ: raise cli.die('cannot compile driver file "%s": %s', driver, e) ns = {'__file__': driver, '__name__': '__omegafig__'} try: exec(code, ns) except Exception as e: if 'OMEGAFIG_BACKTRACE' in os.environ: raise cli.die('cannot execute driver file "%s": %s', driver, e) pfunc = ns.get('plot') if pfunc is None: cli.die('driver file "%s" does not provide a function called "plot"', driver) if not callable(pfunc): cli.die( 'driver file "%s" provides something called "plot", but it\'s ' 'not a function', driver) # Deal with args try: code = pfunc.__code__ except AttributeError: code = pfunc.func_code nargs = code.co_argcount argnames = code.co_varnames keywords = [] nonkeywords = [] for arg in args: if '=' in arg: keywords.append(arg) else: nonkeywords.append(arg) if len(nonkeywords) != nargs: cli.die('expected %d non-keyword arguments to driver, but got %d', nargs, len(nonkeywords)) config = Config() defaults = ns.get('figdefaults') if defaults is not None: for key in defaults: setattr(config, key, defaults[key]) config.parse(keywords) # Set up omegaplot globals as appropriate if config.pango: try: import omega.pango_g3 as ompango except ImportError: import omega.pango_g2 as ompango fontparams = {} if config.pangofamily is not None: fontparams['family'] = config.pangofamily if config.pangosize is not None: fontparams['size'] = config.pangosize if len(fontparams): ompango.setFont(**fontparams) # Execute. p = pfunc(*nonkeywords) if config.out is None: p.show(style=config.omstyle) else: p.save(config.out, style=config.omstyle, dims=config.dims, margins=config.margin)