@ALDAOperator(genericExecutionMode=NONE, level=STANDARD, allowBatchMode=false) public class BoxWhiskerChartPlotter extends MTBOperator
For details on the library take a look here: http://www.jfree.org/jfreechart/
The operator takes input data and generates a box-whisker plot of the data, optionally grouping the boxes into different categories. In addition, the operator provides various parameters to adjust the plot's appearance, like title of the plot, axes labels, or the font size of the tick labels on the axes.
As input data the operator takes a hash map which should contain a key for each category to be displayed, i.e., each group of boxes to appear in the plot, and as values the corresponding data. The data is also expected to be arranged in a hash map where the key string indicates the name of the variable or indicator, and the values are given in terms of a list of doubles.
For an example how the data should look like, consider the following:
assume that we are given two groups of cells, i.e., two categories g1 and g2,
and each group contains 30 elements. For each element two measurements (or
'indicators' in this context) are given, denoted m1 and m2. We would like
to visualize for each group the distribution of the two measurements, i.e.,
get a box plot with two categories and two boxes in each category.
Consequently, we have to pass a hash map to the operator containing
two key-value pairs, one for each category or group, respectively:
[g1, hash_1] , [g2, hash_2]
In each group hash, key-value pairs are expected where the key refers to the
indicator and the value, given in terms of a list, contains the
measurements of the indicator for the elements of that group.
In this example each hash, thus, contains two key-value pairs where the keys
are given by m1 and m2, and each value is given by a list of 30 double
entries:
[m1, [v1, ..., v30] ] , [m2, [v1, ..., v30] ]
For more details on box-whisker plots in JFreeChart, e.g., refer to
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.html
Modifier and Type | Field and Description |
---|---|
protected org.jfree.chart.JFreeChart |
boxWhiskerChart
Resulting box-whisker chart.
|
protected Color[] |
categoryColors
Color map for category colors in plot.
|
private int |
categoryCount
Local variable to store number of categories.
|
protected String |
chartTitle
Title of the chart.
|
protected HashMap<String,HashMap<String,LinkedList<Double>>> |
data
Data to display.
|
protected int |
tickLabelSize
Size of axes' tick labels.
|
protected String |
xLabel
Label of the x-axis.
|
protected String |
yLabel
Label of the y-axis.
|
Constructor and Description |
---|
BoxWhiskerChartPlotter()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
private org.jfree.chart.JFreeChart |
createChart(org.jfree.data.category.CategoryDataset dataset)
Creates the chart.
|
private org.jfree.data.statistics.BoxAndWhiskerCategoryDataset |
createDataset()
Create the dataset from the given input data.
|
org.jfree.chart.JFreeChart |
getChart()
Get reference to resulting chart.
|
protected void |
operate() |
void |
setCategoryColors(Color[] colors)
Specify colors for different categories.
|
void |
setData(HashMap<String,HashMap<String,LinkedList<Double>>> d)
Set the data to plot.
|
void |
setTickLabelSize(int size)
Set size of tick labels on both axes.
|
void |
setTitle(String title)
Set title of chart plot.
|
void |
setXAxisLabel(String xlabel)
Set label of x-axis.
|
void |
setYAxisLabel(String ylabel)
Set label of y-axis.
|
private LinkedList<String> |
sortStringSet(Set<String> input)
Helper method to sort set of strings alphabetically in ascending order.
|
readResolve
addOperatorExecutionProgressEventListener, addParameter, addParameter, addParameterUnconditioned, fieldContained, fireOperatorExecutionProgressEvent, getALDPortHashAccessKey, getConstructionMode, getDocumentation, getHidingMode, getInactiveParameterNames, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterDescriptorUnconditioned, getParameterNames, getParameterUnconditioned, getSupplementalNames, getVerbose, getVersion, handleOperatorExecutionProgressEvent, hasInOutParameters, hasParameter, isAnnotatedParameter, isConfigured, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, removeOperatorExecutionProgressEventListener, removeParameter, runOp, runOp, runOp, setConstructionMode, setConstructionMode, setConstructionMode, setHidingMode, setName, setParameter, setParameterUnconditioned, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory
@Parameter(label="Data", required=true, dataIOOrder=-1, direction=IN, description="Data.", mode=STANDARD) protected HashMap<String,HashMap<String,LinkedList<Double>>> data
@Parameter(label="Chart title", required=false, dataIOOrder=1, direction=IN, description="Chart title.", mode=STANDARD) protected String chartTitle
@Parameter(label="X-axis label", required=false, dataIOOrder=2, direction=IN, description="Label of x-axis.", mode=STANDARD) protected String xLabel
@Parameter(label="Y-axis label", required=false, dataIOOrder=3, direction=IN, description="Label of y-axis.", mode=STANDARD) protected String yLabel
@Parameter(label="Tick label size", required=false, dataIOOrder=4, direction=IN, mode=STANDARD, description="Size of tick labels on both axes.") protected int tickLabelSize
@Parameter(label="Category colors", required=false, dataIOOrder=5, direction=IN, mode=STANDARD, description="List of colors for categories.") protected Color[] categoryColors
@Parameter(label="Box-whisker chart plot", dataIOOrder=1, direction=OUT, description="Resulting plot.", mode=STANDARD) protected org.jfree.chart.JFreeChart boxWhiskerChart
private int categoryCount
public BoxWhiskerChartPlotter() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void setData(HashMap<String,HashMap<String,LinkedList<Double>>> d)
d
- Data to plot.public void setTitle(String title)
title
- Title string.public void setXAxisLabel(String xlabel)
xlabel
- Label string.public void setYAxisLabel(String ylabel)
ylabel
- Label string.public void setTickLabelSize(int size)
size
- Size of tick labels.public void setCategoryColors(Color[] colors)
colors
- List of colors to use for categories.public org.jfree.chart.JFreeChart getChart()
protected void operate() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
operate
in class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
private org.jfree.data.statistics.BoxAndWhiskerCategoryDataset createDataset()
private org.jfree.chart.JFreeChart createChart(org.jfree.data.category.CategoryDataset dataset) throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException, de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
dataset
- The dataset for the chart.de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDProcessingDAGException
private LinkedList<String> sortStringSet(Set<String> input)
input
- Set of strings to sort.Copyright © 2010–2020 Martin Luther University Halle-Wittenberg, Institute of Computer Science, Pattern Recognition and Bioinformatics. All rights reserved.