import statgraphics.StatisticalPlots;
import statgraphics.util.*;
/**
*
* <p>Example: class StatisticalPlots.</p>
*/
pf = new PlotFrame[6];
argument = new Hashtable();
data = new double[12][20];
for (int i = 0; i < 12; i++)
{
for
(int j = 0; j < 20; j++)
{
data[i][j] = -10 + Math.random() * 20.0;
}
}
dataNames = new String[] {"A", "B", "C",
"D", "E", "F", "G", "H",
"I",
"J", "K", "L"};
argument.put(Argument.PLOT_TYPE, PlotType.BOX);
argument.put(Argument.DATA_NAMES, dataNames);
argument.put(Argument.TITLE, "Box Plot");
argument.put(Argument.XLABEL, "Category");
argument.put(Argument.YLABEL, "Data Value");
graphicalAnalysis = new StatisticalPlots(argument,
data).graphicalAnalysis;
plot = graphicalAnalysis.plot;
pf[0] = new PlotFrame("Box Plot II", plot, 500, 270);
date = new Date[12];
for (int i = 0; i < 12; i++)
{
date[i] = new Date(105, i - 1, 21);
}
argument.remove(Argument.DATA_NAMES);
dataObj = new Object[]{date, data};
graphicalAnalysis = new StatisticalPlots(argument,
dataObj).graphicalAnalysis;
plot = graphicalAnalysis.plot;
pf[1] = new PlotFrame("Box Plot III", plot, 500, 270);
double[][] xdata = { {2, 5, 1, 3, 4, 1, 5, 3, 4,
2},
{2,
3, 4, 2, 5, 3, 4, 1, 3, 4} };
double[][] ydata = { {50, 57, 41, 54, 54, 38, 63,
48, 59, 46},
{39, 42, 37, 32, 42, 45, 32, 43, 45, 35} };
dataNames = new String[] {"2004", "2005"};
argument.clear();
argument.put(Argument.PLOT_TYPE, PlotType.SCATTER);
argument.put(Argument.DATA_NAMES, dataNames);
argument.put(Argument.TITLE, "Scatter
Diagram");
argument.put(Argument.XLABEL, "Number of
Commercials");
argument.put(Argument.YLABEL, "Sales");
dataObj = new Object[]{xdata, ydata};
graphicalAnalysis = new StatisticalPlots(argument,
dataObj).graphicalAnalysis;
plot = graphicalAnalysis.plot;
pf[2] = new PlotFrame("Scatter Plot", plot, 500, 270);
double[][] sortXData = { {9, 14, 19, 24, 29, 34},
{11, 13, 17, 22, 26, 28, 31} };
double[][] sortYData = { {0, 4, 12, 17, 19, 20},
{0,
2, 10, 13, 15, 16, 18} };
dataNames = new String[] {"Company A", "Company
B"};
argument.clear();
argument.put(Argument.PLOT_TYPE, PlotType.LINE);
argument.put(Argument.DATA_NAMES, dataNames);
argument.put(Argument.TITLE, "Ogive Plot");
argument.put(Argument.XLABEL, "Audit Time in
Days");
argument.put(Argument.YLABEL, "Cumulative
Frequency");
dataObj = new Object[]{sortXData, sortYData};
graphicalAnalysis = new StatisticalPlots(argument,
dataObj).graphicalAnalysis;
plot = graphicalAnalysis.plot;
pf[3] = new PlotFrame("Ogive Plot",
plot, 500, 270);
double[] variance = {3.59, 1.63, 1.11, 0.70, 0.38, 0.30, 0.14, 0.11};
String[] componentList = {"Comp. 1",
"Comp. 2", "Comp. 3", "Comp. 4",
"Comp. 5",
"Comp. 6", "Comp. 7", "Comp. 8"};
dataNames[0] =
"Component";
argument.put(Argument.DATA_NAMES, dataNames[0]);
argument.put(Argument.TITLE, "Principal
Component Analysis");
argument.put(Argument.XLABEL, "Principal
Component");
argument.put(Argument.YLABEL, "Variance");
dataObj = new Object[]{componentList,
variance};
graphicalAnalysis = new StatisticalPlots(argument,
dataObj).graphicalAnalysis;
plot = graphicalAnalysis.plot;
pf[4] = new PlotFrame("Scree Plot",
plot, 500, 270);
xdata = new double[2][2000];
ydata = new double[2][2000];
dataNames = new String[] {"Power function",
"Sine Function"};
for (int j = 0; j < 2; j++)
{
if
(j == 0)
{
for (int i
= 0; i < 2000; i++)
{
xdata[j][i]
= -10 + 0.01 * i;
ydata[j][i] = Math.pow(xdata[j][i], 2.0);
}
}
else
{
for (int i
= 0; i < 2000; i++)
{
xdata[j][i] = -20 + 0.02 * i;
ydata[j][i] = 100 * Math.sin(xdata[j][i]);
}
}
}
argument.put(Argument.DATA_NAMES, dataNames);
argument.put(Argument.TITLE, "Mathematical
Functions");
argument.put(Argument.XLABEL, "x");
argument.put(Argument.YLABEL, "f(x)");
dataObj = new Object[]{xdata, ydata};
graphicalAnalysis = new StatisticalPlots(argument,
dataObj).graphicalAnalysis;
plot = graphicalAnalysis.plot;
pf[5] = new PlotFrame("Mathematical Functions", plot, 500,
270);
new PlotFrameFactory().putPlotFrame(pf);
Results:





