Skip to Main Content Skip to Search
Product Documentation

plot::Boxplotstatistical box plots

plot::Boxplot(data) creates a box plot of the given data.

→ Examples

Calls:

plot::Boxplot(L1, ..., <a = amin .. amax>, Options)

plot::Boxplot([L1, ...], <a = amin .. amax>, Options)

plot::Boxplot(A, <a = amin .. amax>, Options)

plot::Boxplot(s, <c1, ...>, <a = amin .. amax>, Options)

plot::Boxplot(s, <[c1, ...]>, <a = amin .. amax>, Options)

Parameters:

L1, ...: 

data samples: lists of numerical real values or arithmetical expressions of the animation parameter a
L1, ... is equivalent to the attribute Data.

A

an array of domain type DOM_ARRAY or a matrix of category Cat::Matrix (e.g., of type matrix or densematrix) providing numerical real values or arithmetical expressions of the animation parameter a. The columns are regarded as separate data samples. Also a 1-dimensional array, regarded as a single data sample, is accepted. 
A is equivalent to the attribute Data.

s

a data collection of domain type stats::sample. The columns in s are regarded as separate data samples. 
s is equivalent to the attribute Data.

c1, ...: 

column indices into s: positive integers. These indices, if given, indicate that only the specified columns in s should be used as data samples. If no column indices are specified, all columns in s are used as data samples.

Related Domains:

plot::Bars2d, plot::Bars3d, plot::Histogram2d, plot::Scatterplot

Related Functions:

plot, plot::copy

Details:

image

  • With the special attribute Notched = TRUE, the sides of the boxes can be notched, thus providing additional information on the data sample. The horizontal width of the notches may be set by the attribute NotchWidth.

    Example 1

    Just to show basic usage of plot::Boxplot, we plot some data samples chosen arbitrarily:

    data1 := [5, 10, 24, -4, 13]:
    data2 := [7, 9, -1, 4, 10, 8, 12, 10, 15]:
    b := plot::Boxplot(data1, data2):
    plot(b)

    MuPAD graphics

    We can modify the appearance of the box plot in various ways:

    b::Notched := TRUE:
    b::Colors  := [RGB::Green, RGB::Black]:
    b::BoxCenters := [2, 3]:
    b::FillPattern := XCrossedLines:

    plot(b)

    MuPAD graphics

    delete b:

    Example 2

    It is possible to shift the whole plot in x-direction by providing a center for the first box via BoxCenters:

    A := matrix([[ 5,  6,  19],
                 [10,  5,  45],
                 [24,  2,  12],
                 [-3, 18, -10],
                 [-4,  0, - 4]]):

    plot(plot::Boxplot(A, BoxCenters = [2], Notched = TRUE,
                       FillPattern = Solid))

    MuPAD graphics

    delete A:

    Example 3

    The primary use of plot::Boxplot is comparing data sets. We shall do this for data produced by the following random number generators:

    f := stats::normalRandom(1, 0.2):
    g := stats::uniformRandom(0, 2):

    Now, we create small samples and compare their boxes:

    data1 := [f() $ k = 1..100]: // Red
    data2 := [f() $ k = 1..100]: // Green
    data3 := [g() $ k = 1..100]: // Blue
    plot(plot::Boxplot(data1, data2, data1, data3, data2, data3,
         Colors = [RGB::Red, RGB::Green, RGB::Red, RGB::Blue,
                   RGB::Green, RGB::Blue],
         BoxCenters = [1, 2, 4, 5, 7, 8], Notched = TRUE))

    MuPAD graphics

    Comparing the central boxes, the blue data differ significantly from the red and the green data. The red and green boxes, however, are quite similar – as they should, given that the red and green data were produced by the same random generator f.

    delete f, g, data1, data2, data3:

    Example 4

    For symmetric input data, the images generated by plot::Boxplot are symmetric, too:

    plot(plot::Boxplot([$0..10], [5+5*sin(PI*n/20) $ n=-10..10], Notched))

    MuPAD graphics

    Example 5

    By default, the quantile lines of the boxes are computed with the option Averaged (see stats::empiricalQuantile for details). When using Averaged = FALSE, the quantiles are computed without this option:

    r := random(0..10):
    SEED := 123:
    data := [r() $ k = 1..250]:
    plot(plot::Boxplot(data, Averaged = TRUE, BoxCenters = 0.5, Color = RGB::Blue, Notched),
         plot::Boxplot(data, Averaged = FALSE, BoxCenters = 1.5, Color = RGB::Red, Notched)
        ):

    MuPAD graphics

    delete r, SEED, data:

    Example 6

    Box plots can be animated. We create two data samples and fuse them to a symbolic superposition:

    f1 := stats::normalRandom(0, 1):
    f2 := stats::normalRandom(4, 8):
    data0 := sort([f1() $ k = 1..100]):
    data1 := sort([f2() $ k = 1..100]):
    data01 := [(1 - a)*data0[i] + a*data1[i] $ i = 1..100]:

    The box associated with the data sample data01 changes from the box associated with data0 to the box associated with data1 as the animation parameter increases from a = 0 to a = 1:

    plot(plot::Boxplot(data0, data01, data1, a = 0..1))

    MuPAD graphicsimage

    delete f1, f2, data0, data1, data01:

      


    Recommended Products

    Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

     © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS