def main():
    print '#', ' '.join(sys.argv)
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    #DATA
    parser.add_argument(
        'data_descriptor',
        type=str,
        help=
        'data filename and 0-based columns in this format: 1) filename?y for a single plot, 2) filename?x?y (or filename?x for a countplot) for plots of y-values for each x category, 3) filename?x?y?hue (or filename?x?hue for a countplot) for plots of y-values for each x category and sub-category hue, 4) filename?_?y?hue for plots of y-values for each sub-category hue but with no x categories ("_"), or 5) filename --grid_columns x1 x2 x3 --x_ticks "One" "Two" "Three" --> for a grid-like files where hue is given in column 0, x categories are x1, x2, and x3'
    )
    parser.add_argument(
        '-g',
        '--grid_columns',
        nargs='+',
        type=int,
        help=
        'grid-like (table-like) input where columns are the "x" categories and rows are the "hue" subcategories; the format is then changed so that the first column (index 0) is ALWAYS the labels of the hue subcategories, e.g. filename --grid_columns x1 x2 x3 --x_ticks "One" "Two" "Three"'
    )
    parser.add_argument(
        '-x',
        '--xtics',
        nargs='+',
        type=str,
        help=
        'either specify 1 x-tic when supplying filename?y for a single plot or specify all x-tics when supplying filename --grid_columns (in this case xtics is mandatory)'
    )
    parser.add_argument('--order',
                        nargs='+',
                        type=str,
                        help='the order is given as a list of x categories')
    parser.add_argument(
        '--hue_order',
        nargs='+',
        type=str,
        help='the order is given as a list of hue subcategories')

    #PLOTS
    parser.add_argument('-b',
                        '--box',
                        action='store_true',
                        help='plot a boxplot')
    parser.add_argument('-v',
                        '--violin',
                        action='store_true',
                        help='plot a violinplot')
    parser.add_argument('-r',
                        '--bar',
                        action='store_true',
                        help='plot a barplot')
    parser.add_argument('-r',
                        '--point',
                        action='store_true',
                        help='plot a pointplot')
    parser.add_argument('-c',
                        '--count',
                        action='store_true',
                        help='plot a countplot')
    parser.add_argument('-s',
                        '--swarm',
                        action='store_true',
                        help='plot a swarmplot')
    parser.add_argument('-p',
                        '--strip',
                        action='store_true',
                        help='plot a stripplot')

    #KWARGS
    parser.add_argument(
        '-bk',
        '--box_kwargs',
        nargs='+',
        type=str,
        help=
        '**kwargs for the boxplot, e.g. "color=white edgecolor=gray linewidth=1"'
    )
    parser.add_argument(
        '-vk',
        '--violin_kwargs',
        nargs='+',
        type=str,
        help=
        '**kwargs for the violinplot, e.g. "color=white edgecolor=gray linewidth=1"'
    )
    parser.add_argument(
        '-rk',
        '--bar_kwargs',
        nargs='+',
        type=str,
        help=
        '**kwargs for the barplot, e.g. "color=white edgecolor=gray linewidth=1"'
    )
    parser.add_argument(
        '-rk',
        '--point_kwargs',
        nargs='+',
        type=str,
        help=
        '**kwargs for the pointplot, e.g. "color=white edgecolor=gray linewidth=1"'
    )
    parser.add_argument(
        '-ck',
        '--count_kwargs',
        nargs='+',
        type=str,
        help=
        '**kwargs for the countplot, e.g. "color=white edgecolor=gray linewidth=1"'
    )
    parser.add_argument(
        '-sk',
        '--swarm_kwargs',
        nargs='+',
        type=str,
        help=
        '**kwargs for the swarmplot, e.g. "color=white edgecolor=gray linewidth=1"'
    )
    parser.add_argument(
        '-tk',
        '--strip_kwargs',
        nargs='+',
        type=str,
        help=
        '**kwargs for the stripplot, e.g. "color=white edgecolor=gray linewidth=1"'
    )

    #PLOT-SPECIFIC
    parser.add_argument(
        '--box_outlier',
        type=float,
        help='Size of the markers used to indicate outlier observations',
        default=5)
    parser.add_argument(
        '--box_whis',
        type=float,
        help=
        'Proportion of the IQR past the low and high quartiles to extend the plot whiskers. Points outside this range will be identified as outliers',
        default=1.5)
    parser.add_argument(
        '--box_notch',
        action='store_true',
        help=
        'Whether to notch the box to indicate a confidence interval for the median. There are several other parameters that can control how the notches are drawn; see the plt.boxplot help for more information on them'
    )
    parser.add_argument(
        '--violin_scale',
        choices=['area', 'count', 'width'],
        help=
        'The method used to scale the width of each violin. If area, each violin will have the same area. If count, the width of the violins will be scaled by the number of observations in that bin. If width, each violin will have the same width',
        default='area')
    parser.add_argument(
        '--violin_inner',
        choices=['box', 'quartile', 'point', 'stick', 'None'],
        help=
        'Representation of the datapoints in the violin interior. If box, draw a miniature boxplot. If quartiles, draw the quartiles of the distribution. If point or stick, show each underlying datapoint. Using None will draw unadorned violins',
        default='box')
    parser.add_argument(
        '--violin_cut',
        action='store_true',
        help='limit the violin range within the range of the observed data')
    parser.add_argument(
        '--violin_split',
        action='store_true',
        help=
        'When using hue nesting with a variable that takes two levels, setting split to True will draw half of a violin for each level. This can make it easier to directly compare the distributions'
    )
    parser.add_argument(
        '--violin_scale_hue',
        action='store_true',
        help=
        'When nesting violins using a hue variable, this parameter determines whether the scaling is computed within each level of the major grouping variable (scale_hue=True) or across all the violins on the plot (scale_hue=False)'
    )
    parser.add_argument(
        '--estimator',
        choices=['mean', 'median', 'max', 'min', 'std', 'var', 'sum'],
        help='method to estimate the statistic for the barplot and pointplot',
        default='mean')
    parser.add_argument(
        '--point_markers',
        nargs='+',
        type=str,
        help='string or list (point markers for each of the hue levels)',
        default='o')
    parser.add_argument('--point_marker_size',
                        type=float,
                        help='size of the markers in the pointplot',
                        default=2)
    parser.add_argument('--no_ci',
                        action='store_true',
                        help='do not plot the confidence interval')
    parser.add_argument(
        '--ci',
        type=int,
        help=
        'Size of confidence intervals to draw around estimated values (0...100). If None, no bootstrapping will be performed, and error bars will not be drawn',
        default=95)
    parser.add_argument('--capsize',
                        type=float,
                        help='Width of error line caps)',
                        default=0.2)
    parser.add_argument('--strip_no_jitter',
                        action='store_true',
                        help='do not use jitter for the stripplot')
    parser.add_argument('--black_points',
                        action='store_true',
                        help='Black points for swarm and strip plots')
    parser.add_argument('--transp_points',
                        action='store_true',
                        help='Transparent points for swarm and strip plots')

    # THIS IS NOT WORKING FOR SOME UNKNOWN REASON
    parser.add_argument('--horizontal',
                        action='store_true',
                        help='place y-axis horizontally (swap x and y)')

    plot_utils.add_common_arguments(parser, 'whitegrid_ticks')
    args = parser.parse_args()
    if args.black_points and args.transp_points:
        parser.error(
            'Cannot do black points and transparent points at the same time, choose one of the two options'
        )
    try:
        plot_distro(data=None,
                    data_descriptor=args.data_descriptor,
                    grid_columns=args.grid_columns,
                    x_tics=args.xtics,
                    y_tics=args.ytics,
                    linewidth=args.linewidth,
                    box_plot=args.box,
                    violin_plot=args.violin,
                    bar_plot=args.bar,
                    point_plot=args.point,
                    count_plot=args.count,
                    swarm_plot=args.swarm,
                    strip_plot=args.strip,
                    y_range=args.yrange,
                    x_log=args.xlog,
                    y_log=args.ylog,
                    sep=args.sep,
                    horizontal=args.horizontal,
                    order=args.order,
                    hue_order=args.hue_order,
                    box_outlier=args.box_outlier,
                    box_whis=args.box_whis,
                    box_notch=args.box_notch,
                    violin_scale=args.violin_scale,
                    violin_inner=args.violin_inner
                    if args.violin_inner != 'None' else None,
                    violin_cut=0 if args.violin_cut else 2,
                    violin_split=args.violin_split,
                    violin_scale_hue=args.violin_scale_hue,
                    estimator=plot_utils.ESTIMATORS[args.estimator],
                    ci=args.ci if not args.no_ci else None,
                    capsize=args.capsize,
                    strip_jitter=not args.strip_no_jitter,
                    points_colour='none' if args.transp_points else
                    ('black' if args.black_points else None),
                    point_markers=args.point_markers,
                    point_marker_size=args.point_marker_size,
                    title=args.title,
                    x_label=args.xlabel,
                    y_label=args.ylabel,
                    rotate_x_tics=args.rotate_xtics,
                    bold_x_tics=args.bold_xtics,
                    hide_x_tick_marks=args.hide_xtick_marks,
                    hide_y_tick_marks=args.hide_ytick_marks,
                    hide_x_ticks=args.hide_xticks,
                    hide_y_ticks=args.hide_yticks,
                    label=args.label,
                    show_legend=not args.hide_legend,
                    legend_out=args.legend_out,
                    legend_out_pad=args.legend_out_pad,
                    despine=args.despine,
                    style=args.style,
                    fontsize=args.fontsize,
                    colours=args.colours,
                    palette=args.palette,
                    reverse_palette=args.reverse_palette,
                    ncolours=args.ncolours,
                    figsize=args.figsize,
                    fig_padding=args.fig_padding,
                    dpi=args.dpi,
                    output=args.output,
                    out_format=args.format,
                    box_kwargs=plot_utils.str_to_kwargs(args.box_kwargs)
                    if args.box_kwargs is not None else None,
                    violin_kwargs=plot_utils.str_to_kwargs(args.violin_kwargs)
                    if args.violin_kwargs is not None else None,
                    bar_kwargs=plot_utils.str_to_kwargs(args.bar_kwargs)
                    if args.bar_kwargs is not None else None,
                    point_kwargs=plot_utils.str_to_kwargs(args.point_kwargs)
                    if args.point_kwargs is not None else None,
                    count_kwargs=plot_utils.str_to_kwargs(args.count_kwargs)
                    if args.count_kwargs is not None else None,
                    swarm_kwargs=plot_utils.str_to_kwargs(args.swarm_kwargs)
                    if args.swarm_kwargs is not None else None,
                    strip_kwargs=plot_utils.str_to_kwargs(args.strip_kwargs)
                    if args.strip_kwargs is not None else None,
                    legend_kwargs=plot_utils.str_to_kwargs(args.legend_kwargs)
                    if args.legend_kwargs is not None else None,
                    kwargs=plot_utils.str_to_kwargs(args.kwargs)
                    if args.kwargs is not None else None)
    except PlotsError as e:
        parser.error(e.message)
Exemple #2
0
def main():
    print '#', ' '.join(sys.argv)
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument(
        'data_descriptors',
        nargs='+',
        type=str,
        help=
        'list of data filenames and 0-based columns in this format: 1) multiple files: filenameA?columnX filenameB?columnY ... or 2) single file: filenameA?columnX?columnY?columnZ'
    )
    parser.add_argument('--labels',
                        nargs='+',
                        type=str,
                        help='labels for different curves')
    parser.add_argument('--hide_auc',
                        action='store_true',
                        help='do not calculate and show AUC in the legend')
    plot_utils.add_common_arguments(parser, 'despine_ticks')
    args = parser.parse_args()

    try:
        plot_curves(data=None,
                    data_descriptors=args.data_descriptors,
                    labels=args.labels,
                    linewidth=args.linewidth,
                    y_tics=args.ytics,
                    x_range=args.xrange,
                    y_range=args.yrange,
                    x_log=args.xlog,
                    y_log=args.ylog,
                    sep=args.sep,
                    title=args.title,
                    x_label=args.xlabel,
                    y_label=args.ylabel,
                    rotate_x_tics=args.rotate_xtics,
                    bold_x_tics=args.bold_xtics,
                    hide_x_tick_marks=args.hide_xtick_marks,
                    hide_y_tick_marks=args.hide_ytick_marks,
                    hide_x_ticks=args.hide_xticks,
                    hide_y_ticks=args.hide_yticks,
                    label=args.label,
                    show_legend=not args.hide_legend,
                    legend_out=args.legend_out,
                    legend_out_pad=args.legend_out_pad,
                    show_auc=not args.hide_auc,
                    despine=args.despine,
                    style=args.style,
                    fontsize=args.fontsize,
                    colours=args.colours,
                    palette=args.palette,
                    reverse_palette=args.reverse_palette,
                    ncolours=args.ncolours,
                    figsize=args.figsize,
                    fig_padding=args.fig_padding,
                    dpi=args.dpi,
                    output=args.output,
                    out_format=args.format,
                    kwargs=plot_utils.str_to_kwargs(args.kwargs)
                    if args.kwargs is not None else None)
    except PlotsError as e:
        parser.error(e.message)
Exemple #3
0
def main():
	print '#', ' '.join(sys.argv)
	parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
	parser.add_argument('data_descriptors', nargs='+', type=str, help='list of data filenames and 0-based columns in this format: 1) multiple files: filenameA?columnX filenameB?columnY ... or 2) single file: filenameA?columnX?columnY?columnZ (please note different behaviour depending on if --groups or --factors are specified)')
	parser.add_argument('--groups', nargs='+', type=int, help='list of numbers to represent how many data items from "data_descriptors" to plot into a single plot (mutually exclusive with --factors); DEFAULT: "None" means all data items specified in "data_descriptors" into a single plot; USAGE: "fnA?colX fnB?colY fnC?colZ --groups 2 1" will produce two plots with the first plot plotting two data items "fnA?colX fnB?colY" and the second plot plotting 1 data item "fnC?colZ"')
	parser.add_argument('--factors', nargs='+', type=str, help='list of factors filenames and 0-based columns in this format: 1) multiple files: filenameF?columnK filenameG?columnL ... or 2) single file: filenameF?columnK?columnL?columnM or 3) single file with a single factor column: filenameF?columnK; this means that each data item specified in "data_descriptors" will produce its own plot with several histograms based on the defined factors (mutually exclusive with --groups); DEFAULT: "None" means there are no factors and each data item produces a single histogram; USAGE: "fnA?colX fnB?colY fnC?colZ --factors fnF?colK fnG?colL fnH?colM" will make three plots each with as many histogram as there are factors in fnF?colK, fnG?colL, and fnH?colM')
	parser.add_argument('--labels', nargs='+', type=str, help='labels for the data: label1 label2 ...; the number of labels needs to be equal to the number of data items in "data_descriptors" but if --factors are specified, each factor needs its own label for each data item')
	parser.add_argument('--auto_labels', action='store_true', help='labels for the data will be parsed from the first line of the file which has to start with "#"')
	parser.add_argument('--nbins', type=int, help='how many bins to plot in the histogram (mutually exclusive with --binw)')
	parser.add_argument('--binw', type=float, help='width of the bin (mutually exclusive with --nbins)')
	parser.add_argument('--no_hist', action='store_true', help='do NOT plot histogram')
	parser.add_argument('--kde', action='store_true', help='to add a density plot (estimated with KDE)')
	parser.add_argument('--rug', action='store_true', help='to add a rug plot')
	parser.add_argument('--normed', action='store_true', help='to plot density of a histogram instead of frequency (if --kde is set, density is always plotted)')
	parser.add_argument('--hide_binw', action='store_true', help='hide the bin width text label')
	parser.add_argument('--ncols', type=int, help='how many plots should be in a single row')
	plot_utils.add_common_arguments(parser, 'despine_ticks')
	args = parser.parse_args()
	try:
		plot_hist(data=None, data_descriptors=args.data_descriptors, labels=args.labels, auto_labels=args.auto_labels, y_tics=args.ytics, linewidth=args.linewidth, nbins=args.nbins, binw=args.binw, groups=args.groups, factors=args.factors, ncols=args.ncols, x_range=args.xrange, y_range=args.yrange, x_log=args.xlog, y_log=args.ylog, sep=args.sep, hist=not args.no_hist, kde=args.kde, rug=args.rug, normed=args.normed, title=args.title, x_label=args.xlabel, y_label=args.ylabel, rotate_x_tics=args.rotate_xtics, bold_x_tics=args.bold_xtics, hide_x_tick_marks=args.hide_xtick_marks, hide_y_tick_marks=args.hide_ytick_marks, hide_x_ticks=args.hide_xticks, hide_y_ticks=args.hide_yticks, label=args.label, show_binw=not args.hide_binw, show_legend=not args.hide_legend, legend_out=args.legend_out, legend_out_pad=args.legend_out_pad, despine=args.despine, style=args.style, fontsize=args.fontsize, colours=args.colours, palette=args.palette, reverse_palette=args.reverse_palette, ncolours=args.ncolours, figsize=args.figsize, fig_padding=args.fig_padding, dpi=args.dpi, output=args.output, out_format=args.format, kwargs=plot_utils.str_to_kwargs(args.kwargs) if args.kwargs is not None else None)
	except PlotsError as e:
		parser.error(e.message)
Exemple #4
0
def main():
    print '#', ' '.join(sys.argv)
    parser = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument(
        'data_descriptors',
        nargs='+',
        type=str,
        help=
        'list of data filenames and 0-based columns in this format: 1) multiple files: filenameA?columnX filenameB?columnY or 2) single file: filenameA?columnX?columnY'
    )
    parser.add_argument(
        '--auto_labels',
        action='store_true',
        help=
        'labels for the data will be parsed from the first line of the file which has to start with "#"'
    )
    parser.add_argument(
        '--hide_corr',
        action='store_true',
        help='do not calculate and plot Pearson correlation (r)')
    parser.add_argument('--fit_reg',
                        action='store_true',
                        help='regression line')
    parser.add_argument('--ci',
                        type=int,
                        help='confidence interval 0...100 or None')
    plot_utils.add_common_arguments(parser, 'despine_ticks')
    args = parser.parse_args()
    try:
        plot_scatter(x=None,
                     y=None,
                     data_descriptors=args.data_descriptors,
                     linewidth=args.linewidth,
                     y_tics=args.ytics,
                     x_range=args.xrange,
                     y_range=args.yrange,
                     x_log=args.xlog,
                     y_log=args.ylog,
                     sep=args.sep,
                     title=args.title,
                     x_label=args.xlabel,
                     y_label=args.ylabel,
                     rotate_x_tics=args.rotate_xtics,
                     bold_x_tics=args.bold_xtics,
                     hide_x_tick_marks=args.hide_xtick_marks,
                     hide_y_tick_marks=args.hide_ytick_marks,
                     hide_x_ticks=args.hide_xticks,
                     hide_y_ticks=args.hide_yticks,
                     auto_labels=args.auto_labels,
                     label=args.label,
                     show_corr=not args.hide_corr,
                     show_legend=not args.hide_legend,
                     legend_out=args.legend_out,
                     legend_out_pad=args.legend_out_pad,
                     fit_reg=args.fit_reg,
                     ci=args.ci,
                     despine=args.despine,
                     style=args.style,
                     fontsize=args.fontsize,
                     colours=args.colours,
                     palette=args.palette,
                     reverse_palette=args.reverse_palette,
                     ncolours=args.ncolours,
                     figsize=args.figsize,
                     fig_padding=args.fig_padding,
                     dpi=args.dpi,
                     output=args.output,
                     out_format=args.format,
                     kwargs=plot_utils.str_to_kwargs(args.kwargs)
                     if args.kwargs is not None else None)
    except PlotsError as e:
        parser.error(e.message)