def hist(self, *columns, overlay=True, bins=None, bin_column=None, unit=None, counts=None, group=None, side_by_side=False, width=<NUM_LIT:6>, height=<NUM_LIT:4>, **vargs):
if counts is not None and bin_column is None:<EOL><INDENT>warnings.warn("<STR_LIT>")<EOL>bin_column=counts<EOL><DEDENT>if columns:<EOL><INDENT>columns_included = list(columns)<EOL>if bin_column is not None:<EOL><INDENT>columns_included.append(bin_column)<EOL><DEDENT>if group is not None:<EOL><INDENT>columns_included.append(group)<EOL><DEDENT>self = self.select(*columns_included)<EOL><DEDENT>if group is not None:<EOL><INDENT>if bin_column is not None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if len(columns) > <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>for col in self:<EOL><INDENT>if col != group and any(isinstance(cell, np.flexible) for cell in self[col]):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>.format(col))<EOL><DEDENT><DEDENT>if bin_column is not None and bins is None:<EOL><INDENT>bins = np.unique(self.column(bin_column))<EOL><DEDENT>if bins is not None:<EOL><INDENT>vargs['<STR_LIT>'] = bins<EOL><DEDENT>if '<STR_LIT>' not in vargs and '<STR_LIT>' not in vargs:<EOL><INDENT>vargs['<STR_LIT>'] = True<EOL><DEDENT>elif '<STR_LIT>' in vargs and '<STR_LIT>' not in vargs:<EOL><INDENT>vargs['<STR_LIT>'] = vargs.pop('<STR_LIT>')<EOL><DEDENT>elif '<STR_LIT>' in vargs and '<STR_LIT>' in vargs:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>def prepare_hist_with_bin_column(bin_column):<EOL><INDENT>weight_columns = [c for c in self.labels if c != bin_column]<EOL>bin_values = self.column(bin_column)<EOL>values_dict = [(w.rstrip('<STR_LIT>'), (bin_values, self.column(w))) for w in weight_columns]<EOL>return values_dict<EOL><DEDENT>def prepare_hist_with_group(group):<EOL><INDENT>grouped = self.group(group, np.array)<EOL>if grouped.num_rows > <NUM_LIT:20>:<EOL><INDENT>warnings.warn("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>.format(grouped.num_rows))<EOL><DEDENT>return [("<STR_LIT>".format(group, k), (v[<NUM_LIT:0>][<NUM_LIT:1>],)) for k, v in grouped.index_by(group).items()]<EOL><DEDENT>if bin_column is not None:<EOL><INDENT>values_dict = prepare_hist_with_bin_column(bin_column)<EOL><DEDENT>elif group is not None:<EOL><INDENT>values_dict = prepare_hist_with_group(group)<EOL><DEDENT>else:<EOL><INDENT>values_dict = [(k, (self.column(k),)) for k in self.labels]<EOL><DEDENT>values_dict = collections.OrderedDict(values_dict)<EOL>def draw_hist(values_dict):<EOL><INDENT>n = len(values_dict)<EOL>colors = [rgb_color + (self.default_alpha,) for rgb_color in<EOL>itertools.islice(itertools.cycle(self.chart_colors), n)]<EOL>hist_names = list(values_dict.keys())<EOL>values = [v[<NUM_LIT:0>] for v in values_dict.values()]<EOL>weights = [v[<NUM_LIT:1>] for v in values_dict.values() if len(v) > <NUM_LIT:1>]<EOL>if n > len(weights) > <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if vargs['<STR_LIT>']:<EOL><INDENT>y_label = '<STR_LIT>' + (unit if unit else '<STR_LIT>')<EOL>percentage = plt.FuncFormatter(lambda x, _: "<STR_LIT>".format(<NUM_LIT:100>*x))<EOL><DEDENT>else:<EOL><INDENT>y_label = '<STR_LIT>'<EOL><DEDENT>if overlay and n > <NUM_LIT:1>:<EOL><INDENT>values = values[::-<NUM_LIT:1>]<EOL>weights = weights[::-<NUM_LIT:1>]<EOL>colors = list(colors)[::-<NUM_LIT:1>]<EOL>if len(weights) == n:<EOL><INDENT>vargs['<STR_LIT>'] = weights<EOL><DEDENT>if not side_by_side:<EOL><INDENT>vargs.setdefault('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>figure = plt.figure(figsize=(width, height))<EOL>plt.hist(values, color=colors, **vargs)<EOL>axis = figure.get_axes()[<NUM_LIT:0>]<EOL>_vertical_x(axis)<EOL>axis.set_ylabel(y_label)<EOL>if vargs['<STR_LIT>']:<EOL><INDENT>axis.yaxis.set_major_formatter(percentage)<EOL><DEDENT>if unit:<EOL><INDENT>axis.set_xlabel('<STR_LIT:(>' + unit + '<STR_LIT:)>', fontsize=<NUM_LIT:16>)<EOL><DEDENT>plt.legend(hist_names, loc=<NUM_LIT:2>, bbox_to_anchor=(<NUM_LIT>, <NUM_LIT:1>))<EOL>type(self).plots.append(axis)<EOL><DEDENT>else:<EOL><INDENT>_, axes = plt.subplots(n, <NUM_LIT:1>, figsize=(width, height * n))<EOL>if '<STR_LIT>' in vargs:<EOL><INDENT>bins = vargs['<STR_LIT>']<EOL>if isinstance(bins, numbers.Integral) and bins > <NUM_LIT> or hasattr(bins, '<STR_LIT>') and len(bins) > <NUM_LIT>:<EOL><INDENT>vargs.setdefault('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT><DEDENT>if n == <NUM_LIT:1>:<EOL><INDENT>axes = [axes]<EOL><DEDENT>for i, (axis, hist_name, values_for_hist, color) in enumerate(zip(axes, hist_names, values, colors)):<EOL><INDENT>axis.set_ylabel(y_label)<EOL>if vargs['<STR_LIT>']:<EOL><INDENT>axis.yaxis.set_major_formatter(percentage)<EOL><DEDENT>x_unit = '<STR_LIT>' + unit + '<STR_LIT:)>' if unit else '<STR_LIT>'<EOL>if len(weights) == n:<EOL><INDENT>vargs['<STR_LIT>'] = weights[i]<EOL><DEDENT>axis.set_xlabel(hist_name + x_unit, fontsize=<NUM_LIT:16>)<EOL>axis.hist(values_for_hist, color=color, **vargs)<EOL>_vertical_x(axis)<EOL>type(self).plots.append(axis)<EOL><DEDENT><DEDENT><DEDENT>draw_hist(values_dict)<EOL>
Plots one histogram for each column in columns. If no column is
        specified, plot all columns.

        Kwargs:
            overlay (bool): If True, plots 1 chart with all the histograms
                overlaid on top of each other (instead of the default behavior
                of one histogram for each column in the table). Also adds a
                legend that matches each bar color to its column.  Note that
                if the histograms are not overlaid, they are not forced to the
                same scale.

            bins (list or int): Lower bound for each bin in the
                histogram or number of bins. If None, bins will
                be chosen automatically.

            bin_column (column name or index): A column of bin lower bounds.
                All other columns are treated as counts of these bins.
                If None, each value in each row is assigned a count of 1.

            counts (column name or index): Deprecated name for bin_column.

            unit (string): A name for the units of the plotted column (e.g.
                'kg'), to be used in the plot.

            group (column name or index): A column of categories.  The rows are
                grouped by the values in this column, and a separate histogram is
                generated for each group.  The histograms are overlaid or plotted
                separately depending on the overlay argument.  If None, no such
                grouping is done.

            side_by_side (bool): Whether histogram bins should be plotted side by
                side (instead of directly overlaid).  Makes sense only when
                plotting multiple histograms, either by passing several columns
                or by using the group option.

            vargs: Additional arguments that get passed into :func:plt.hist.
                See http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.hist
                for additional arguments that can be passed into vargs. These
                include: `range`, `normed`/`density`, `cumulative`, and
                `orientation`, to name a few.

        >>> t = Table().with_columns(
        ...     'count',  make_array(9, 3, 3, 1),
        ...     'points', make_array(1, 2, 2, 10))
        >>> t
        count | points
        9     | 1
        3     | 2
        3     | 2
        1     | 10
        >>> t.hist() # doctest: +SKIP
        <histogram of values in count>
        <histogram of values in points>

        >>> t = Table().with_columns(
        ...     'value',      make_array(101, 102, 103),
        ...     'proportion', make_array(0.25, 0.5, 0.25))
        >>> t.hist(bin_column='value') # doctest: +SKIP
        <histogram of values weighted by corresponding proportions>

        >>> t = Table().with_columns(
        ...     'value',    make_array(1,   2,   3,   2,   5  ),
        ...     'category', make_array('a', 'a', 'a', 'b', 'b'))
        >>> t.hist('value', group='category') # doctest: +SKIP
        <two overlaid histograms of the data [1, 2, 3] and [2, 5]>