BoxWhiskerChart

BoxWhiskerChart[{x1,x2,}]

makes a boxandwhisker chart for the values xi.

BoxWhiskerChart[{x1,x2,},bwspec]

makes a chart with boxandwhisker symbol specification bwspec.

BoxWhiskerChart[{data1,data2,},]

makes a chart with boxandwhisker symbol for each datai.

BoxWhiskerChart[{{data1,data2,},},]

makes a boxandwhisker chart from multiple groups of datasets {data1,data2,}.

Details and Options

  • BoxWhiskerChart draws a box-and-whisker summary of the distribution of values in each datai.
  • The following box-and-whisker specifications bwspec can be given:
  • "Notched"median confidence interval notch
    "Outliers"outlier markers
    "Median"median marker
    "Basic"box-and-whisker only
    "Mean"mean marker
    "Diamond"mean confidence interval diamond
    {{elem1,val11,},}box-and-whisker element specification
    {"name",{elem1,val11,},}named bwspec with element modifications
  • The elements and values include:
  • {"Fences",width,style}width and style of fences
    {"MeanDiamond",width,style}width and style of mean confidence interval
    {"MeanMarker",width,style}width and style of mean marker line
    {"MedianNotch",width,style}width and style of median confidence interval
    {"MedianMarker",width,style}width and style of median marker line
    {"Outliers",marker,style}marker symbol and style for outliers
    {"FarOutliers",marker,style}marker symbol and style for far outliers
    {"Whiskers",style}style for whiskers
  • The width is given as a fraction of the width of the box, and the marker can be any expression.
  • Data elements for BoxWhiskerChart can be given in the following forms:
  • dataia pure dataset
    Quantity[datai,unit]data datai with units
    wi[datai,]data datai with wrapper wi
    formi->midata with metadata mi
  • Each datai should be a list of real numbers {y1,y2,}. Elements yj that are not real numbers are taken to be missing and are excluded. If datai is not a list of real numbers, it is taken to be missing data and will typically result in the gap in the box-and-whisker chart.
  • Datasets for BoxWhiskerChart can be given in the following forms:
  • {data1,data2,}list of elements with or without wrappers
    <|k1data1,k2data2,|>association of keys and datasets
    TimeSeries[],EventSeries[],TemporalData[]time series, event series, and temporal data
    WeightedData[],EventData[]augmented datasets
    w[{data1,data2,},]wrapper applied to a grouped dataset
    w[{{data1,data1,},},]wrapper applied to all grouped datasets
  • Possible symbolic wrappers are the same as for BarChart and include Style, Labeled, Legended, etc.
  • In BoxWhiskerChart, Labeled and Placed allow the following positions:
  • Top,Bottom,Left,Right,Centerpositions within the box
    Above, Below, Before, Afterpositions outside the box and other elements
    Axison the bar origin axis
    "LowerFence","LowerQuartile","MedianMarker","MeanMarker","UpperQuartile","UpperFence"positions given by box-and-whisker elements
    {{bx,by},{lx,ly}}scaled position {lx,ly} in the label at scaled position {bx,by} for the box-and-whisker elements
  • BoxWhiskerChart has the same options as Graphics, with the following additions and changes:
  • AspectRatio1/GoldenRatiooverall ratio of width to height
    BarOriginBottomwhere to place smallest value for box-and-whisker
    BarSpacingAutomaticfractional spacing between box-and-whiskers
    ChartBaseStyleAutomaticoverall style for box-and-whiskers
    ChartElementFunctionAutomatichow to generate raw graphics for box
    ChartLabelsNonelabels for data elements and datasets
    ChartLegendsNonelegends for data elements and datasets
    ChartStyleAutomaticstyle for box
    FrameTruewhether to draw a frame around the chart
    JoinedFalsewhether to join medians
    LabelingFunctionAutomatichow to label box-and-whisker elements
    LabelingSizeAutomaticmaximum size of callouts and labels
    LegendAppearanceAutomaticoverall appearance of legends
    MethodAutomaticwhat methods to use
    PerformanceGoal$PerformanceGoalaspects of performance to try to optimize
    PlotTheme$PlotThemeoverall theme for the chart
    ScalingFunctionsNonehow to scale individual coordinates
    TargetUnitsAutomaticunits to display in the chart
  • The arguments supplied to ChartElementFunction are the box region {{xmin,xmax},{ymin,ymax}}, the data datai, and metadata {m1,m2,} from each level in a nested list of datasets.
  • A list of built-in settings for ChartElementFunction can be obtained from ChartElementData["BoxWhiskerChart"].
  • With ScalingFunctions->s, the data coordinate is scaled using s.
  • Style and other specifications from options and other constructs in BoxWhiskerChart are effectively applied in the order ChartStyle, Style and other wrappers, and ChartElementFunction, with later specifications overriding earlier ones.

Examples

open allclose all

Basic Examples  (6)

Generate a box-and-whisker chart for a data vector:

Generate a box-and-whisker chart for a list of data vectors:

Chart several collections of datasets:

Customize the appearance of the box-and-whisker chart:

Show outliers:

Use categorical labels:

Categorical legends:

Show outliers:

Show notches for the median confidence interval:

Scope  (45)

Data and Wrappers  (17)

Single data vector:

Multiple data vectors:

Data vectors in a dataset are grouped together:

Datasets do not need to have the same number of data vectors:

Nonreal data is taken to be missing and typically yields a gap in the box-and-whisker chart:

A nonreal entry in a data vector is omitted:

The data may include units:

Specify the units to use:

The time stamps in TimeSeries, EventSeries, and TemporalData are ignored:

The values in associations are taken as the heights of the bars:

Use the keys as labels:

Use the keys as legends:

Associations can be nested:

Use WeightedData to add weights to data:

Use EventData to add censoring and truncation information:

Use wrappers on an individual data vector, datasets, or collections of datasets:

Inner wrappers take precedence over outer wrappers:

Override the default tooltips:

Use PopupWindow to provide additional drilldown information:

Use the other charting function in PopupWindow to provide more information:

Button can be used to trigger any action:

Elements  (11)

Use named presets:

Style the whiskers:

Vary the width of the fences:

Style the fences:

Use different shapes for outliers:

Style the outliers:

Use different shapes for far outliers:

Style the far outliers:

Vary the width of the median marker:

Style the median marker:

Use a different shape of median marker:

Do not show the median marker:

Vary the width of the median confidence interval:

Style the median confidence interval:

Vary the width of the mean marker:

Style the mean marker:

Use a different shape of mean marker:

Vary the width of the mean confidence interval:

Style the mean confidence interval:

Combine individual elements with named presets:

Combine elements with ChartElementFunction:

Styling and Appearance  (9)

Use an explicit list of styles for the box-and-whiskers:

Use any gradient or indexed color schemes from ColorData:

Use color schemes designed for charting:

ChartBaseStyle can be used to set an initial style for all chart elements:

Style can be used to override styles:

Use built-in programmatically generated bars:

For detailed settings use Palettes ChartElementSchemes:

Use a theme with simple ticks and grid lines:

Use a theme with detailed ticks and a reference line:

Change the origin of box-and-whiskers:

Adjust the spacing between individuals and groups of box-and-whiskers:

Labeling and Legending  (8)

Use Labeled to add a label to a box-and-whisker:

Use symbolic positions for label placement:

Provide categorical labels for the columns of data:

For rows of data:

For both:

Use Placed to control the positioning of labels, using the same positions as for Labeled:

Provide value labels for box-and-whisker by using LabelingFunction:

Use Placed to control placement and formatting:

Add categorical legend entries for the columns of data:

For rows of data:

Use Legended to add additional legend entries:

Use Placed to affect the positioning of legends:

Options  (41)

BarOrigin  (1)

Change the bar origin:

BarSpacing  (4)

BoxWhiskerChart automatically selects the spacing between bars:

With groups of data:

Use symbolic spacing:

With groups of data:

Use explicit spacing between bars:

With groups of data:

Use no bar spacing:

Within groups of data:

ChartBaseStyle  (3)

Use ChartBaseStyle to style box-and-whisker charts:

ChartBaseStyle combines with ChartStyle:

ChartStyle may override settings for ChartBaseStyle:

ChartElementFunction  (3)

Get a list of built-in settings for ChartElementFunction:

For detailed settings, use Palettes ChartElementSchemes:

Use named specifications with ChartElementFunction:

ChartLabels  (9)

By default labels are placed under the frame:

Use Placed to control label placement:

Symbolic positions outside the bar:

Use positions relative to the box-and-whisker charts:

Use group labels to label groups:

Coordinate-based placement relative to a bar:

Place all labels at the upper-right corner and vary the coordinates within the label:

Use the third argument to Placed to control formatting:

Place multiple labels:

ChartLegends  (1)

Generate a legend based on chart style:

Place the legend below the chart:

ChartStyle  (5)

Use ChartStyle to style the bars:

Give a list of styles:

Use "Gradient" colors from ColorData:

Use "Indexed" colors from ColorData:

Styles are used cyclically:

Style datasets in a group:

Style groups of datasets:

Element styles override ChartStyle:

Joined  (1)

Join the medians of the datasets:

LabelingFunction  (2)

By default, bars have tooltips with a summary table of the data:

Define a labeling function and place it in a tooltip:

LabelingSize  (4)

Textual labels are shown at their actual sizes:

Image labels are automatically resized:

Specify a maximum size for textual labels:

Specify a maximum size for image labels:

Show image labels at their natural sizes:

Method  (3)

Use bar widths proportional to the square root of the data sizes:

Put bars on fixed positions with varying bar spacing:

Use constant-width bars:

BoxWhiskerChart uses Quartiles to calculate quartiles and extremes:

Use Quantile instead:

Use Quantile with parameters for mode-based estimates:

Create a box-whisker plot using precomputed statistics:

PerformanceGoal  (3)

Generate a box-and-whisker chart with interactive highlighting:

Emphasize performance by disabling interactive behaviors:

Typically less memory is required for non-interactive charts:

PlotTheme  (2)

Use a theme with a high contrast color scheme and glassy rectangle boxes:

Change the chart style:

Applications  (3)

Compare the distribution of salaries for several departments at a university:

A -test for equal location of two populations effectively checks for overlap in confidence intervals about their means. BoxWhiskerChart can be used to perform a visual -test:

The mean diamonds do not overlap. The null hypothesis is rejected at the 5% level:

The mean diamonds overlap. There is not enough evidence to reject the null hypothesis:

Compare different time slices of a random process:

Properties & Relations  (6)

Outliers and far outliers are defined using the quartiles and interquartile range:

Use DistributionChart to show distribution of data:

BoxWhiskerChart is a case of DistributionChart:

Use Histogram and SmoothHistogram to visualize a list of data vectors:

Use QuantilePlot and ProbabilityPlot to compare data to distributions:

Use Histogram3D and SmoothHistogram3D to visualize two-dimensional data vectors:

Introduced in 2010
 (8.0)
 |
Updated in 2012
 (9.0)
2014
 (10.0)
2018
 (11.3)