iqplot.histogram

iqplot.histogram(data=None, q=None, cats=None, palette=None, order=None, q_axis='x', p=None, rug=None, rug_height=None, show_legend=None, legend_label=None, legend_location='right', legend_orientation='vertical', legend_click_policy='hide', tooltips=None, bins='freedman-diaconis', density=False, style=None, arrangement=None, mirror=False, hist_height=0.75, conf_int=False, ptiles=(2.5, 97.5), n_bs_reps=10000, line_kwargs=None, fill_kwargs=None, rug_kwargs=None, conf_int_kwargs=None, horizontal=None, val=None, click_policy=None, kind=None, **kwargs)

Make a plot of histograms.

Parameters:
  • data (Pandas DataFrame, 1D Numpy array, or xarray) – DataFrame containing tidy data for plotting. If a Numpy array, a single category is assumed and a box plot generated from data.

  • q (hashable) – Name of column to use as quantitative variable if data is a Pandas DataFrame. Otherwise, q is used as the quantitative axis label.

  • cats (hashable or list of hashables) – Name of column(s) to use as categorical variable(s).

  • q_axis (str, either 'x' or 'y', default 'x') – Axis along which the quantitative value varies.

  • palette (list colors, or single color string) – If a list, color palette to use. If a single string representing a color, all glyphs are colored with that color. Default is colorcet.b_glasbey_category10 from the colorcet package.

  • order (list or None) – If not None, must be a list of unique group names when the input data frame is grouped by cats. The order of the list specifies the ordering of the categorical variables in the legend. If None, the categories appear in the order in which they appeared in the inputted data frame.

  • p (bokeh.plotting.Figure instance, or None (default)) – If None, create a new figure. Otherwise, populate the existing figure p.

  • rug (bool, default True) – If True, also include a rug plot. If, however, bins is ‘exact’ or ‘integer’, the rug kwarg is ignored.

  • rug_height (float, default None) – Height of the rug plot as a fraction of the highest point in the histograms. For ‘overlay’ arrangement, default is 0.05. For ‘stacked’ arrangement, default is 0.2.

  • legend_label (str, default None) – If cats is None and show_legend is True, then if legend_label is not None, a legend is created for the glyph on the plot and labeled with legend_label. Otherwise, no legend is created if cats is None.

  • legend_location (str, default 'right') – Location of legend. If one of “right”, “left”, “above”, or “below”, the legend is placed outside of the plot area. If one of “top_left”, “top_center”, “top_right”, “center_right”, “bottom_right”, “bottom_center”, “bottom_left”, “center_left”, or “center”, the legend is placed within the plot area. If a 2-tuple, legend is placed according to the coordinates in the tuple.

  • legend_orientation (str, default 'vertical') – Either ‘horizontal’ or ‘vertical’.

  • legend_click_policy (str, default 'hide') – Either ‘hide’, ‘mute’, or None; how the glyphs respond when the corresponding category is clicked in the legend.

  • tooltips (list of 2-tuples) – Specification for tooltips as per Bokeh specifications. For example, if we want col1 and col2 tooltips, we can use tooltips=[(‘label 1’: ‘@col1’), (‘label 2’: ‘@col2’)]. Ignored if rug is False.

  • bins (int, array_like, or str, default 'freedman-diaconis') – If int or array_like, setting for bins kwarg to be passed to np.histogram(). If ‘exact’, then each unique value in the data gets its own bin. If ‘integer’, then integer data is assumed and each integer gets its own bin. If ‘sqrt’, uses the square root rule to determine number of bins. If freedman-diaconis, uses the Freedman-Diaconis rule for number of bins.

  • density (bool, default False) – If True, normalize the histograms. Otherwise, base the histograms on counts.

  • style (None or one of ['step', 'step_filled']) – Default for overlayed histograms is ‘step’ and for stacked histograms ‘step_filled’. The exception is when cont_int is True, in which case style must be ‘step’.

  • arrangement ('stack' or 'overlay') – Arrangement of histograms. If ‘overlay’, histograms are overlaid on the same plot. If ‘stack’, histograms are stacked one on top of the other. By default, if cats is None or there is only one category, arrangement is ‘overlay’, and if there is more than one category, arrangement is ‘stack’.

  • mirror (bool, default False) – If True, reflect the histogram through zero. Ignored if arrangement == ‘overlay’.

  • hist_height (float, default 0.75) – Maximal height of histogram or its confidence interval as a fraction of available height along categorical axis. Only active when arrangement is ‘stack’.

  • conf_int (bool, default False) – If True, display confidence interval of histogram.

  • ptiles (list, default [2.5, 97.5]) – The percentiles to use for the confidence interval. Ignored if conf_int is False.

  • n_bs_reps (int, default 10,000) – Number of bootstrap replicates to do to compute confidence interval. Ignored if conf_int is False.

  • line_kwargs (dict) – Keyword arguments to pass to p.line() in constructing the histograms. By default, {“line_width”: 2}.

  • fill_kwargs (dict) – Keyword arguments to pass to p.patch() when making the fill for the step-filled histogram or confidence intervals. Ignored if style = ‘step’ and conf_int is False. By default {“fill_alpha”: 0.3, “line_alpha”: 0}.

  • rug_kwargs (dict) – Keyword arguments to pass to p.multi_line() when making the rug plot.

  • horizontal (bool or None, default None) – Deprecated. Use q_axis.

  • val (hashable) – Deprecated, use q.

  • click_policy (str, default 'hide') – Deprecated. Use legend_click_policy.

  • conf_int_kwargs (dict) – Deprecated. Use fill_kwargs.

  • kind (str, default 'step_filled') – Deprecated. Use style.

  • kwargs – Any kwargs to be passed to bokeh.plotting.figure() when making the plot.

Returns:

output – Figure populated with histograms.

Return type:

Bokeh figure

Notes