def main():
    """
    %prog numbers1.txt number2.txt ...

    Print histogram of the data files. The data files contain one number per
    line. If more than one file is inputted, the program will combine the
    histograms into the same plot.
    """
    allowed_format = ("emf", "eps", "pdf", "png", "ps", \
                      "raw", "rgba", "svg", "svgz")
    p = OptionParser(main.__doc__)
    p.add_option("--skip", default=0, type="int",
            help="skip the first several lines [default: %default]")
    p.add_option("--col", default=0, type="int", help="Get the n-th column")
    p.set_histogram()
    p.add_option("--tags", dest="tags", default=None,
            help="tags for data if multiple input files, comma sep")
    p.add_option("--ascii", default=False, action="store_true",
            help="print ASCII text stem-leaf plot [default: %default]")
    p.add_option("--base", default="0", choices=("0", "2", "10"),
            help="use logarithm axis with base, 0 to disable [default: %default]")
    p.add_option("--facet", default=False, action="store_true",
            help="place multiple histograms side-by-side [default: %default]")
    p.add_option("--fill", default="white",
            help="color of the bin [default: %default]")
    p.add_option("--format", default="pdf", choices=allowed_format,
            help="Generate image of format [default: %default]")
    p.add_option("--quick", default=False, action="store_true",
            help="Use quick plot, assuming bins are already counted")
    p.add_option("--noprintstats", default=False, action="store_true",
            help="Write basic stats when using --quick")
    opts, args = p.parse_args()

    if len(args) < 1:
        sys.exit(not p.print_help())

    skip = opts.skip
    vmin, vmax = opts.vmin, opts.vmax
    bins = opts.bins
    xlabel, title = opts.xlabel, opts.title
    title = title or args[0]
    base = int(opts.base)
    fileno = len(args)

    if opts.quick:
        assert fileno == 1, "Single input file expected using --quick"
        filename = args[0]
        figname = filename.rsplit(".", 1)[0] + ".pdf"
        data = DictFile(filename, keycast=int, cast=int)
        quickplot(data, vmin, vmax, xlabel, title, figname=figname,
                  print_stats=(not opts.noprintstats))
        return

    if fileno == 1:
        histogram(args[0], vmin, vmax, xlabel, title, outfmt=opts.format,
                bins=bins, skip=skip, ascii=opts.ascii,
                base=base, fill=opts.fill, col=opts.col)
    else:
        histogram_multiple(args, vmin, vmax, xlabel, title, outfmt=opts.format,
                tags=opts.tags, bins=bins, skip=skip, ascii=opts.ascii,
                facet=opts.facet, fill=opts.fill)
def main ( ) : allowed_format = ( "emf" , "eps" , "pdf" , "png" , "ps" , "raw" , "rgba" , "svg" , "svgz" ) p = OptionParser ( main . __doc__ ) p . add_option ( "--skip" , default = 0 , type = "int" , help = "skip the first several lines [default: %default]" ) p . add_option ( "--col" , default = 0 , type = "int" , help = "Get the n-th column" ) p . set_histogram ( ) p . add_option ( "--tags" , dest = "tags" , default = None , help = "tags for data if multiple input files, comma sep" ) p . add_option ( "--ascii" , default = False , action = "store_true" , help = "print ASCII text stem-leaf plot [default: %default]" ) p . add_option ( "--base" , default = "0" , choices = ( "0" , "2" , "10" ) , help = "use logarithm axis with base, 0 to disable [default: %default]" ) p . add_option ( "--facet" , default = False , action = "store_true" , help = "place multiple histograms side-by-side [default: %default]" ) p . add_option ( "--fill" , default = "white" , help = "color of the bin [default: %default]" ) p . add_option ( "--format" , default = "pdf" , choices = allowed_format , help = "Generate image of format [default: %default]" ) p . add_option ( "--quick" , default = False , action = "store_true" , help = "Use quick plot, assuming bins are already counted" ) p . add_option ( "--noprintstats" , default = False , action = "store_true" , help = "Write basic stats when using --quick" ) opts , args = p . parse_args ( ) if len ( args ) < 1 : sys . exit ( not p . print_help ( ) ) skip = opts . skip vmin , vmax = opts . vmin , opts . vmax bins = opts . bins xlabel , title = opts . xlabel , opts . title title = title or args [ 0 ] base = int ( opts . base ) fileno = len ( args ) if opts . quick : assert fileno == 1 , "Single input file expected using --quick" filename = args [ 0 ] figname = filename . rsplit ( "." , 1 ) [ 0 ] + ".pdf" data = DictFile ( filename , keycast = int , cast = int ) quickplot ( data , vmin , vmax , xlabel , title , figname = figname , print_stats = ( not opts . noprintstats ) ) return if fileno == 1 : histogram ( args [ 0 ] , vmin , vmax , xlabel , title , outfmt = opts . format , bins = bins , skip = skip , ascii = opts . ascii , base = base , fill = opts . fill , col = opts . col ) else : histogram_multiple ( args , vmin , vmax , xlabel , title , outfmt = opts . format , tags = opts . tags , bins = bins , skip = skip , ascii = opts . ascii , facet = opts . facet , fill = opts . fill )
%prog numbers1.txt number2.txt ...

    Print histogram of the data files. The data files contain one number per
    line. If more than one file is inputted, the program will combine the
    histograms into the same plot.