Class BoxPlotSeries


public class BoxPlotSeries extends XYSeries

Box and whisker plots: the median, the interquartile box and the whiskers of each group.

Give it the five numbers directly or let it compute them from raw samples:

double[] mondaySamples = {120, 135, 150, 180, 240};
double[] tuesdaySamples = {110, 125, 140, 160, 300};
BoxPlotSeries s = new BoxPlotSeries("Latency");
s.addSamples(0, mondaySamples);
s.addSamples(1, tuesdaySamples);

A box plot

  • Constructor Details

    • BoxPlotSeries

      public BoxPlotSeries(String name)

      Creates an empty series.

      Parameters
      • name: the series name
  • Method Details

    • addBox

      public BoxPlotSeries addBox(double x, double min, double q1, double median, double q3, double max)

      Appends a box from its five numbers.

      Parameters
      • x: the group's x value

      • min: the lower whisker

      • q1: the first quartile

      • median: the median

      • q3: the third quartile

      • max: the upper whisker

      Returns

      this series

    • addSamples

      public BoxPlotSeries addSamples(double x, double[] samples)

      Appends a box computed from raw samples. The whiskers reach the furthest samples within 1.5 times the interquartile range of the box (Tukey's rule) and every sample beyond them is an outlier, drawn as a dot and returned by getOutliers(int).

      Parameters
      • x: the group's x value

      • samples: the values; the array is not modified

      Returns

      this series

    • getOutliers

      public double[] getOutliers(int i)

      The outliers of box i: the samples addSamples placed beyond the whiskers. A box given by addBox has none.

      Parameters
      • i: the box index
      Returns

      a new array, empty when there are none

    • getMin

      public double getMin(int i)

      The lower whisker of box i.

      Parameters
      • i: the box index
      Returns

      the lower whisker's value

    • getMax

      public double getMax(int i)

      The upper whisker of box i.

      Parameters
      • i: the box index
      Returns

      the upper whisker's value

    • dataChanged

      protected void dataChanged()
      Forgets the outliers of boxes that are no longer in the series, such as one a slide dropped; they are dropped when the outliers are next read.
      Overrides:
      dataChanged in class XYSeries
    • quantile

      public static double quantile(double[] sorted, double q)

      Linear interpolated quantile of sorted data.

      Parameters
      • sorted: ascending values

      • q: the quantile, 0 to 1

      Returns

      the quantile

    • setBoxFraction

      public BoxPlotSeries setBoxFraction(float f)

      The fraction of each slot a box takes.

      Parameters
      • f: 0.1 to 1
      Returns

      this series

    • getYBounds

      public double[] getYBounds()
      Description copied from class: Series
      The extent of the data along y, {min, max}, or null when empty or not cartesian.
      Overrides:
      getYBounds in class XYSeries
    • getXBounds

      public double[] getXBounds()
      Description copied from class: Series
      The extent of the data along x, {min, max}, or null when empty or not cartesian.
      Overrides:
      getXBounds in class XYSeries
    • paint

      public void paint(ChartContext ctx)
      Description copied from class: Series

      Paints the series.

      Parameters
      • ctx: the current frame: graphics, plot area, axes and animation progress
      Specified by:
      paint in class Series
    • formatTooltip

      public String formatTooltip(ChartContext ctx, ChartPoint p)
      Description copied from class: Series

      The tooltip row for a point: the series or point name and its formatted value. Series with several values per point (open/high/low/close, ranges, box plots) override this.

      Parameters
      • ctx: the last paint context

      • p: the point

      Returns

      one line of text

      Overrides:
      formatTooltip in class Series
    • tableValue

      protected String tableValue(int i)
      Description copied from class: XYSeries

      The text of point i in the accessible data table.

      Parameters
      • i: the point index
      Returns

      the formatted value

      Overrides:
      tableValue in class XYSeries