Class 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 Details

    • BoxPlot

      public BoxPlot(double[][] data, String[] labels)
      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

      public Optional<String> tooltip(double[] coord)
      Description copied from class: Plot
      Returns a optional tool tip for the object at given coordinates.
      Overrides:
      tooltip in class Plot
      Parameters:
      coord - the logical coordinates of current mouse position.
      Returns:
      a string if an object with label close to the given coordinates.
    • getLowerBound

      public double[] getLowerBound()
      Description copied from class: Plot
      Returns the lower bound of data.
      Specified by:
      getLowerBound in class Plot
    • getUpperBound

      public double[] getUpperBound()
      Description copied from class: Plot
      Returns the upper bound of data.
      Specified by:
      getUpperBound in class Plot
    • paint

      public void paint(Graphics g)
      Description copied from class: Shape
      Draws the shape.
      Specified by:
      paint in class Shape
    • canvas

      public Canvas canvas()
      Description copied from class: Plot
      Returns a canvas of the plot.
      Overrides:
      canvas in class Plot
    • of

      public static BoxPlot of(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.