iqplot.spike

iqplot.spike(data=None, q=None, cats=None, palette=None, order=None, q_axis='x', p=None, show_legend=None, legend_label=None, legend_location='right', legend_orientation='vertical', legend_click_policy='hide', fraction=False, style=None, arrangement=None, spike_height=0.75, conf_int=False, ptiles=(2.5, 97.5), n_bs_reps=10000, line_kwargs=None, marker_kwargs=None, horizontal=None, val=None, click_policy=None, density=None, **kwargs)

Make a spike plot.

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.

  • 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.

  • fraction (bool, default False) – If True, the spike height is given by the fraction of data points having the given value. Otherwise, the height of a spike is given by the count of data points having the given value.

  • style (None or one of ['spike', 'spike-dot', 'dot']) – ‘spike’ gives a traditional spike plot. ‘spike-dot’ additionally features dots on top of the spikes, similar in appearance to a lollipop plot. ‘dot’ has the dot at the top of the spike, but the spike is not shown. Default is ‘spike-dot’, unless conf_int is True and the number of categorial values is greater than one, in which case the default is ‘dot’ (and only ‘dot’ is allowed) for confidence intervals to avoid clashes.

  • arrangement ('stack' or 'overlay', default 'stack') – Arrangement of spike plots. If ‘overlay’, spikes are overlaid on the same plot. If ‘stack’, spikes are stacked one on top of the other.

  • spike_height (float, default 0.75) – Maximal height of spike 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 the spikes.

  • ptiles (list with two elements, 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.

  • marker_kwargs (dict) – Keyword arguments to be passed to p.scatter() for dots at the top of spikes.

  • line_kwargs (dict) – Keyword arguments to pass to p.segment() in constructing the spikes and confidence intervals. By default, {“line_width”: 2}.

  • 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.

  • 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