de.erichseifert.gral.plots
Class BoxPlot
- java.lang.Object
-
- All Implemented Interfaces:
- DataListener, Container, Drawable, Navigable, AxisListener, Plot, java.io.Serializable, java.lang.Iterable<Drawable>
public class BoxPlot extends XYPlot
Class that displays data as a box-and-whisker plot showing summaries of important statistical values. The data source must provide six columns to the
BoxPlot:- Box position (for multiple boxes)
- Position of the center bar (e.g. median)
- Length of the lower whisker and position of the bottom bar (e.g. minimum)
- Position of the bottom edge of the box (e.g. first quartile)
- Position of the top edge of the box (e.g. third quartile)
- Length of the upper whisker and position of the top bar (e.g. maximum)
The utility method
createBoxData(DataSource)can be used to obtain common statistics for these properties from the each column of an existing data source.To create a new
BoxPlotsimply create a new instance using a data source. Example:DataTable data = new DataTable(Double.class, Double.class); data.add(10.98, -12.34); data.add( 7.65, 45.67); data.add(43.21, 89.01); DataSource boxData = BoxPlot.createBoxData(data); BoxPlot plot = new BoxPlot(boxData);
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classBoxPlot.BoxPlotLegendA legend implementation for box-and-whisker plots that displays all values of the data source as items.static classBoxPlot.BoxWhiskerRendererClass that renders a box and its whiskers in a box-and-whisker plot.-
Nested classes/interfaces inherited from class de.erichseifert.gral.plots.XYPlot
XYPlot.XYLegend, XYPlot.XYNavigationDirection, XYPlot.XYPlotArea2D, XYPlot.XYPlotNavigator
-
-
Constructor Summary
Constructors Constructor and Description BoxPlot(DataSource data)Initializes a new box-and-whisker plot with the specified data source.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(int index, DataSource source, boolean visible)Inserts the specified data series to the plot at a specified position.voidautoscaleAxis(java.lang.String axisName)Tries to automatically set the ranges of the axes specified by the name if it is set to auto-scale.static DataSourcecreateBoxData(DataSource data)Extracts statistics from the columns of an data source that are commonly used for box-and-whisker plots.-
Methods inherited from class de.erichseifert.gral.plots.XYPlot
addPointRenderer, draw, getAreaRenderers, getLineRenderers, getNavigator, getPointRenderers, rangeChanged, removePointRenderer, setAreaRenderers, setAreaRenderers, setAxisRenderer, setLineRenderers, setLineRenderers, setPointRenderers, setPointRenderers
-
Methods inherited from class de.erichseifert.gral.plots.AbstractPlot
add, add, clear, contains, dataAdded, dataRemoved, dataUpdated, get, getAxesNames, getAxis, getAxisRenderer, getBackground, getBorderColor, getBorderStroke, getData, getFont, getLegend, getLegendDistance, getLegendLocation, getMapping, getPlotArea, getTitle, getVisibleData, isLegendVisible, isVisible, layout, remove, removeAxis, setAxis, setBackground, setBorderColor, setBorderStroke, setFont, setLegendDistance, setLegendLocation, setLegendVisible, setMapping, setVisible
-
Methods inherited from class de.erichseifert.gral.graphics.DrawableContainer
add, add, contains, getConstraints, getDrawables, getDrawablesAt, getInsets, getLayout, getPreferredSize, iterator, remove, setBounds, setBounds, setInsets, setLayout, size
-
Methods inherited from class de.erichseifert.gral.graphics.AbstractDrawable
getBounds, getHeight, getWidth, getX, getY, setPosition
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.erichseifert.gral.graphics.Drawable
getBounds, getHeight, getPreferredSize, getWidth, getX, getY, setBounds, setBounds, setPosition
-
Methods inherited from interface de.erichseifert.gral.graphics.Container
add, add, contains, getBounds, getConstraints, getDrawables, getDrawablesAt, getInsets, getLayout, remove, setBounds, setInsets, setLayout, size
-
-
-
-
Constructor Detail
-
BoxPlot
public BoxPlot(DataSource data)
Initializes a new box-and-whisker plot with the specified data source.- Parameters:
data- Data to be displayed.
-
-
Method Detail
-
createBoxData
public static DataSource createBoxData(DataSource data)
Extracts statistics from the columns of an data source that are commonly used for box-and-whisker plots. The result is a new data source containing column index, median, mininum, first quartile, third quartile, and maximum for each column.- Parameters:
data- Original data source- Returns:
- New data source with (columnIndex, median, min, quartile1, quartile3, max)
-
add
public void add(int index, DataSource source, boolean visible)Description copied from class:AbstractPlotInserts the specified data series to the plot at a specified position.
-
autoscaleAxis
public void autoscaleAxis(java.lang.String axisName)
Description copied from class:AbstractPlotTries to automatically set the ranges of the axes specified by the name if it is set to auto-scale.- Specified by:
autoscaleAxisin interfacePlot- Overrides:
autoscaleAxisin classAbstractPlot- Parameters:
axisName- Name of the axis that should be scaled.- See Also:
Axis.setAutoscaled(boolean)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG