smile.plot
Class BoxPlot
- java.lang.Object
-
- smile.plot.Shape
-
- smile.plot.Plot
-
- smile.plot.BoxPlot
-
public class BoxPlot extends Plot
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
Constructors Constructor and Description BoxPlot(double[] data)Constructor.BoxPlot(double[][] data)Constructor.BoxPlot(java.lang.String[] description, double[][] data)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description java.lang.StringgetToolTip(double[] coord)Returns a optional tool tip for the object at given coordinates.voidpaint(Graphics g)Draw the component with given graphics object.static PlotCanvasplot(double[]... data)Create a plot canvas with multiple box plots of given data.static PlotCanvasplot(double[] data)Create a plot canvas with the box plot of given data.static PlotCanvasplot(double[][] data, java.lang.String[] labels)Create a plot canvas with multiple box plots of given data.-
Methods inherited from class smile.plot.Plot
getID, getToolBar, setID
-
-
-
-
Constructor Detail
-
BoxPlot
public BoxPlot(double[] data)
Constructor.
-
BoxPlot
public BoxPlot(double[][] data)
Constructor.- Parameters:
data- the input dataset of which each row is a set of samples and will have a corresponding box plot.
-
BoxPlot
public BoxPlot(java.lang.String[] description, double[][] data)Constructor.- Parameters:
data- the input dataset of which each row is a set of samples and will have a corresponding box plot.
-
-
Method Detail
-
getToolTip
public java.lang.String getToolTip(double[] coord)
Description copied from class:PlotReturns a optional tool tip for the object at given coordinates.- Overrides:
getToolTipin classPlot- Parameters:
coord- the logical coordinates of current mouse position.- Returns:
- a string if an object with label close to the given coordinates. Otherwise null.
-
paint
public void paint(Graphics g)
Description copied from class:ShapeDraw the component with given graphics object.
-
plot
public static PlotCanvas plot(double[] data)
Create a plot canvas with the box plot of given data.- Parameters:
data- a sample set.
-
plot
public static PlotCanvas plot(double[]... data)
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.
-
plot
public static PlotCanvas plot(double[][] data, java.lang.String[] labels)
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.labels- the labels for each box plot.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG