iqplot.box

iqplot.box(data=None, q=None, cats=None, q_axis='x', palette=None, order=None, p=None, whisker_caps=False, display_points=True, outlier_marker='circle', min_data=5, cat_grid=False, box_kwargs=None, median_kwargs=None, whisker_kwargs=None, outlier_kwargs=None, display_outliers=None, horizontal=None, val=None, **kwargs)

Make a box-and-whisker 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 with a single box is 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 of strings of hex colors, or single hex string) – If a list, color palette to use. If a single string representing a hex 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 on the categorical axis and 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.

  • whisker_caps (bool, default False) – If True, put caps on whiskers. If False, omit caps.

  • display_points (bool, default True) – If True, display outliers and any other points that arise from categories with fewer than min_data data points; otherwise suppress them. This should only be False when using the boxes as annotation on another plot.

  • outlier_marker (str, default 'circle') – Name of marker to be used in the plot (ignored if formal is False). Must be one of[‘asterisk’, ‘circle’, ‘circle_cross’, ‘circle_x’, ‘cross’, ‘dash’, ‘diamond’, ‘diamond_cross’, ‘hex’, ‘inverted_triangle’, ‘square’, ‘square_cross’, ‘square_x’, ‘triangle’, ‘x’]

  • min_data (int, default 5) – Minimum number of data points in a given category in order to make a box and whisker. Otherwise, individual data points are plotted as in a strip plot.

  • cat_grid (bool, default False) – If True, display grid line for categorical axis.

  • box_kwargs (dict, default None) – A dictionary of kwargs to be passed into p.hbar() or p.vbar() when constructing the boxes for the box plot.

  • median_kwargs (dict, default None) – A dictionary of kwargs to be passed into p.hbar() or p.vbar() when constructing the median line for the box plot.

  • whisker_kwargs (dict, default None) – A dictionary of kwargs to be passed into p.segment() when constructing the whiskers for the box plot.

  • outlier_kwargs (dict, default None) – A dictionary of kwargs to be passed into p.scatter() when constructing the outliers for the box plot.

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

  • val (hashable) – Deprecated, use q.

  • kwargs – Kwargs that are passed to bokeh.plotting.figure() in contructing the figure.

Returns:

output – Plot populated with box-and-whisker plot.

Return type:

bokeh.plotting.Figure instance

Notes

Uses the Tukey convention for box plots. The top and bottom of the box are respectively the 75th and 25th percentiles of the data. The line in the middle of the box is the median. The top whisker extends to the maximum of the set of data points that are less than 1.5 times the IQR beyond the top of the box, with an analogous definition for the lower whisker. Data points not between the ends of the whiskers are considered outliers and are plotted as individual points.