Package smile.plot.swing
Class BoxPlot
java.lang.Object
smile.plot.swing.Shape
smile.plot.swing.Plot
smile.plot.swing.BoxPlot
A boxplot is a convenient way of graphically depicting groups of numerical
data through their five-number summaries the smallest observation
(sample minimum), lower quartile (Q1), median (Q2), upper quartile (Q3),
and largest observation (sample maximum). A boxplot may also indicate
which observations, if any, might be considered outliers.
Boxplots can be useful to display differences between populations without making any assumptions of the underlying statistical distribution: they are non-parametric. The spacings between the different parts of the box help indicate the degree of dispersion (spread) and skewness in the data, and identify outliers.
For a data set, we construct a boxplot in the following manner:
- Calculate the first q1, the median q2 and third quartile q3.
- Calculate the interquartile range (IQR) by subtracting the first quartile from the third quartile. (q3 ? q1)
- Construct a box above the number line bounded on the bottom by the first quartile (q1) and on the top by the third quartile (q3).
- Indicate where the median lies inside of the box with the presence of a line dividing the box at the median value.
- Any data observation which lies more than 1.5*IQR lower than the first quartile or 1.5IQR higher than the third quartile is considered an outlier. Indicate where the smallest value that is not an outlier is by connecting it to the box with a horizontal line or "whisker". Optionally, also mark the position of this value more clearly using a small vertical line. Likewise, connect the largest value that is not an outlier to the box by a "whisker" (and optionally mark it with another small vertical line).
- Indicate outliers by dots.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncanvas()
Returns a canvas of the plot.double[]
Returns the lower bound of data.double[]
Returns the upper bound of data.static BoxPlot
of
(double[]... data) Create a plot canvas with multiple box plots of given data.void
Draws the shape.tooltip
(double[] coord) Returns an optional tooltip for the object at given coordinates.
-
Constructor Details
-
BoxPlot
Constructor.- Parameters:
data
- the input dataset of which each row is a set of samples and will have a corresponding box plot.
-
-
Method Details
-
tooltip
Description copied from class:Plot
Returns an optional tooltip for the object at given coordinates. -
getLowerBound
public double[] getLowerBound()Description copied from class:Plot
Returns the lower bound of data.- Specified by:
getLowerBound
in classPlot
-
getUpperBound
public double[] getUpperBound()Description copied from class:Plot
Returns the upper bound of data.- Specified by:
getUpperBound
in classPlot
-
paint
Description copied from class:Shape
Draws the shape. -
canvas
Description copied from class:Plot
Returns a canvas of the plot. -
of
Create a plot canvas with multiple box plots of given data.- Parameters:
data
- a data matrix of which each row will create a box plot.
-