@ALDAOperator(genericExecutionMode=NONE, level=STANDARD, allowBatchMode=false) public class StackedBarChartPlotter extends MTBOperator
For details on the library take a look here: http://www.jfree.org/jfreechart/
The operator takes input data and generates a stacked bar plot from the data. It 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 item to be displayed, i.e., for each column to appear in the plot, and a list of row indizes or 'indicators' with corresponding values which should be plotted for each item. Note that the row indizes for different items should be identical.
For an example how the data should look like, consider the following:
assume that we are given three different experimental settings e1, e2 and
e3, and for each setting we acquire four measurements (or 'indicators' in
this context), denoted m1, m2, m3 and m4. To visualize the data in a
stacked bar plot we have to pass a hash map to the operator containing
three key-value pairs, one for each experimental setting:
[e1, hash_1] , [e2, hash_2], [e3, hash_3]
In each hash key-value pairs are expected specifying the values for the
different indicators in the experiment, e.g., hash_1 should contain the
following elements:
[m1, 'value of m1 in e1'], ..., [m4, 'value of m4 in e1']
For details on stacked bar plots in JFreeChart, e.g., refer to
http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.html
Modifier and Type | Field and Description |
---|---|
protected Color[] |
categoryColors
Color map for category colors in plot.
|
protected String |
chartTitle
Title of the chart.
|
protected HashMap<String,HashMap<String,Double>> |
data
Data to display.
|
protected org.jfree.chart.JFreeChart |
stackedBarChart
Resulting stacked bar chart.
|
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 |
---|
StackedBarChartPlotter()
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.category.CategoryDataset |
createDataset()
Create the dataset from 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,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,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="Chart Plot", dataIOOrder=1, direction=OUT, description="Resulting chart plot.", mode=STANDARD) protected org.jfree.chart.JFreeChart stackedBarChart
public StackedBarChartPlotter() throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
public void setData(HashMap<String,HashMap<String,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.category.CategoryDataset 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.