Package org.moeaframework.analysis.plot
Class XYPlotBuilder
java.lang.Object
org.moeaframework.analysis.plot.PlotBuilder<XYPlotBuilder>
org.moeaframework.analysis.plot.XYPlotBuilder
Builds 2D plots with numeric X and Y axes, including line, scatter, area, stacked area, and deviation plots.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.moeaframework.analysis.plot.PlotBuilder
PlotBuilder.DisplayDriver
-
Field Summary
Fields inherited from class org.moeaframework.analysis.plot.PlotBuilder
paintHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarea
(String label, double[] x, double[] y, PlotAttribute... attributes) Creates a new area plot series.Creates a new area plot series.<D> XYPlotBuilder
area
(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new area plot series.area
(String label, Partition<? extends Number, ? extends Number> partition, PlotAttribute... attributes) Creates a new area plot series.org.jfree.chart.JFreeChart
build()
Builds and returns the configured plot.deviation
(String label, double[] x, double[] y, PlotAttribute... attributes) Creates a new deviation series.deviation
(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes) Creates a new deviation series.<D> XYPlotBuilder
deviation
(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new deviation series.deviation
(String label, List<ResultSeries> data, String property, PlotAttribute... attributes) Creates a new deviation series, with a solid line indicating the median (50-th percentile) and a shaded area denoting the lower and upper percentiles.protected RectangularShape
Returns the default shape used when rendering points.protected Stroke
Returns the default stroke used when rendering lines.protected XYPlotBuilder
Returns an instance of this builder cast to the concrete implementation typePlotBuilder
.Sets the grid line paint for both axes.histogram
(String label, double[] values, PlotAttribute... attributes) Creates a new histogram showing the number of times each value occurs in the input.histogram
(String label, List<? extends Number> values, PlotAttribute... attributes) Creates a new histogram showing the number of times each value occurs in the input.<D> XYPlotBuilder
histogram
(String label, List<D> data, Function<D, ? extends Number> getter, PlotAttribute... attributes) Creates a new histogram showing the number of times each value occurs in the input.line
(String label, double[] x, double[] y, PlotAttribute... attributes) Creates a new line plot series.Creates a new line plot series.<D> XYPlotBuilder
line
(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new line plot series.line
(String label, ResultSeries series, String property, PlotAttribute... attributes) Creates a new line plot series of NFE versus the property value.line
(String label, Partition<? extends Number, ? extends Number> partition, PlotAttribute... attributes) Creates a new line plot series.lines
(ResultSeries series, PlotAttribute... attributes) Creates a new line plot series of NFE versus the property value.Adds a pointer annotation, which includes a label and an arrow, to the plot.scatter
(String label, double[] x, double[] y, PlotAttribute... attributes) Creates a new scatter plot series.scatter
(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes) Creates a new scatter plot series.<D> XYPlotBuilder
scatter
(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new scatter plot series.scatter
(String label, Partition<? extends Number, ? extends Number> partition, PlotAttribute... attributes) Creates a new scatter plot series.scatter
(String label, Population population, int x, int y, PlotAttribute... attributes) Creates a scatter plot representation of the feasible solutions in a population.scatter
(String label, Population population, PlotAttribute... attributes) Creates a scatter plot representation of the feasible solutions in a population.stacked
(String label, double[] x, double[] y, PlotAttribute... attributes) Creates a new stacked area plot series.stacked
(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes) Creates a new stacked area plot series.<D> XYPlotBuilder
stacked
(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new stacked area plot series.stacked
(String label, Partition<? extends Number, ? extends Number> partition, PlotAttribute... attributes) Creates a new stacked area plot series.Adds a label annotation to the plot.Sets the X axis label.xLim
(double min, double max) Sets the X axis limits.xLim
(org.jfree.data.Range range) Sets the X axis limits.Sets the Y axis label.yLim
(double min, double max) Sets the Y axis limits.yLim
(org.jfree.data.Range range) Sets the Y axis limits.Methods inherited from class org.moeaframework.analysis.plot.PlotBuilder
applyStyle, applyStyle, barGraph, boxAndWhisker, build, buildPanel, defaultLegend, getAttribute, getDisplayDriver, getValueOrDefault, getValueOrDefault, hasAttribute, heatMap, legend, noLegend, paintHelper, save, save, save, sensitivity, setDisplayDriver, show, show, subtitle, theme, title, to2DArray, toArray, toArray, xy
-
Constructor Details
-
XYPlotBuilder
public XYPlotBuilder()Constructs a new, empty XY plot.
-
-
Method Details
-
getInstance
Description copied from class:PlotBuilder
Returns an instance of this builder cast to the concrete implementation typePlotBuilder
. This is used by any intermediate classes to returns the concrete implementation.- Specified by:
getInstance
in classPlotBuilder<XYPlotBuilder>
- Returns:
- a reference to this builder instance
-
build
public org.jfree.chart.JFreeChart build()Description copied from class:PlotBuilder
Builds and returns the configured plot.- Specified by:
build
in classPlotBuilder<XYPlotBuilder>
- Returns:
- the resulting plot
-
xLabel
Sets the X axis label.- Parameters:
label
- the label for the X axis- Returns:
- a reference to this builder
-
yLabel
Sets the Y axis label.- Parameters:
label
- the label for the Y axis- Returns:
- a reference to this builder
-
xLim
Sets the X axis limits.- Parameters:
min
- the minimum boundmax
- the maximum bound- Returns:
- a reference to this builder
-
xLim
Sets the X axis limits.- Parameters:
range
- the minimum and maximum bounds- Returns:
- a reference to this builder
-
yLim
Sets the Y axis limits.- Parameters:
min
- the minimum boundmax
- the maximum bound- Returns:
- a reference to this builder
-
yLim
Sets the Y axis limits.- Parameters:
range
- the minimum and maximum bounds- Returns:
- a reference to this builder
-
gridPaint
Sets the grid line paint for both axes.- Parameters:
paint
- the paint- Returns:
- a reference to this builder
-
scatter
Creates a new scatter plot series.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
scatter
public XYPlotBuilder scatter(String label, Partition<? extends Number, ? extends Number> partition, PlotAttribute... attributes) Creates a new scatter plot series.- Parameters:
label
- the label for the seriespartition
- the data stream partitionattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
scatter
public XYPlotBuilder scatter(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes) Creates a new scatter plot series.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
scatter
public <D> XYPlotBuilder scatter(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new scatter plot series.- Type Parameters:
D
- the type of each object- Parameters:
label
- the label for the seriesdata
- the list of objectsxAxis
- a function converting each object into a numeric value for the X axisyAxis
- a function converting each object into a numeric value for the Y axisattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
scatter
Creates a scatter plot representation of the feasible solutions in a population.- Parameters:
label
- the label for the seriespopulation
- the populationattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
scatter
public XYPlotBuilder scatter(String label, Population population, int x, int y, PlotAttribute... attributes) Creates a scatter plot representation of the feasible solutions in a population.- Parameters:
label
- the label for the seriespopulation
- the populationx
- the objective to plot on the X axisy
- the objective to plot on the Y axisattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
line
Creates a new line plot series.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
line
public XYPlotBuilder line(String label, Partition<? extends Number, ? extends Number> partition, PlotAttribute... attributes) Creates a new line plot series.- Parameters:
label
- the label for the seriespartition
- the data stream partitionattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
line
public XYPlotBuilder line(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes) Creates a new line plot series.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
line
public <D> XYPlotBuilder line(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new line plot series.- Type Parameters:
D
- the type of each object- Parameters:
label
- the label for the seriesdata
- the list of objectsxAxis
- a function converting each object into a numeric value for the X axisyAxis
- a function converting each object into a numeric value for the Y axisattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
line
public XYPlotBuilder line(String label, ResultSeries series, String property, PlotAttribute... attributes) Creates a new line plot series of NFE versus the property value.- Parameters:
label
- the label for the seriesseries
- the result seriesproperty
- the name of the property to plotattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
lines
Creates a new line plot series of NFE versus the property value. Each property is rendered as a separate line series.- Parameters:
series
- the result seriesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
histogram
public XYPlotBuilder histogram(String label, List<? extends Number> values, PlotAttribute... attributes) Creates a new histogram showing the number of times each value occurs in the input.- Parameters:
label
- the label for the seriesvalues
- the valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
histogram
public <D> XYPlotBuilder histogram(String label, List<D> data, Function<D, ? extends Number> getter, PlotAttribute... attributes) Creates a new histogram showing the number of times each value occurs in the input.- Type Parameters:
D
- the type of each object- Parameters:
label
- the label for the seriesdata
- the list of objectsgetter
- a function converting each object into a numeric valueattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
histogram
Creates a new histogram showing the number of times each value occurs in the input.- Parameters:
label
- the label for the seriesvalues
- the valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
area
Creates a new area plot series.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
area
public XYPlotBuilder area(String label, Partition<? extends Number, ? extends Number> partition, PlotAttribute... attributes) Creates a new area plot series.- Parameters:
label
- the label for the seriespartition
- the data stream partitionattributes
- the attributes configuring the plot- Returns:
- a reference to this instance
-
area
public XYPlotBuilder area(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes) Creates a new area plot series.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
area
public <D> XYPlotBuilder area(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new area plot series.- Type Parameters:
D
- the type of each object- Parameters:
label
- the label for the seriesdata
- the list of objectsxAxis
- a function converting each object into a numeric value for the X axisyAxis
- a function converting each object into a numeric value for the Y axisattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
stacked
Creates a new stacked area plot series.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
stacked
public XYPlotBuilder stacked(String label, Partition<? extends Number, ? extends Number> partition, PlotAttribute... attributes) Creates a new stacked area plot series.- Parameters:
label
- the label for the seriespartition
- the data stream partitionattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
stacked
public XYPlotBuilder stacked(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes) Creates a new stacked area plot series.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
stacked
public <D> XYPlotBuilder stacked(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new stacked area plot series.- Type Parameters:
D
- the type of each object- Parameters:
label
- the label for the seriesdata
- the list of objectsxAxis
- a function converting each object into a numeric value for the X axisyAxis
- a function converting each object into a numeric value for the Y axisattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
deviation
public XYPlotBuilder deviation(String label, List<ResultSeries> data, String property, PlotAttribute... attributes) Creates a new deviation series, with a solid line indicating the median (50-th percentile) and a shaded area denoting the lower and upper percentiles.- Parameters:
label
- the label for the seriesdata
- a collection of theResultSeries
to displayproperty
- the property to displayattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
deviation
public <D> XYPlotBuilder deviation(String label, List<D> data, Function<D, ? extends Number> xAxis, Function<D, ? extends Number> yAxis, PlotAttribute... attributes) Creates a new deviation series.- Type Parameters:
D
- the type of each object- Parameters:
label
- the label for the seriesdata
- the list of objectsxAxis
- a function converting each object into a numeric value for the X axisyAxis
- a function converting each object into a numeric value for the Y axisattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
deviation
public XYPlotBuilder deviation(String label, List<? extends Number> x, List<? extends Number> y, PlotAttribute... attributes) Creates a new deviation series. The data is aggregated using a given step size, with the median, low-percentile, and high-percentile values computed from the points lying within each step.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
deviation
Creates a new deviation series. The data is aggregated using a given step size, with the median, low-percentile, and high-percentile values computed from the points lying within each step.- Parameters:
label
- the label for the seriesx
- the X valuesy
- the Y valuesattributes
- the attributes configuring the plot- Returns:
- a reference to this builder
-
text
Adds a label annotation to the plot.- Parameters:
text
- the text to displayx
- the position of the label along the X axisy
- the position of hte label along the Y axis- Returns:
- a reference to this builder
-
pointer
Adds a pointer annotation, which includes a label and an arrow, to the plot.- Parameters:
text
- the text to displayx
- the target position of the arrow along the X axisy
- the target position of the arrow along the Y axisangle
- the angle, in radians, of the arrow and label in relation to the target position- Returns:
- a reference to this builder
-
getDefaultStroke
Returns the default stroke used when rendering lines.- Returns:
- the default stroke
-
getDefaultShape
Returns the default shape used when rendering points.- Returns:
- the default shape
-