StatBean Name: ContourPlot

Purpose: Creates contour plots for a response surface.

DataSource: any.


Read/Write Properties
NameTypeDescriptionPossible ValuesDefault Value
addPointsbooleanWhether to add points around the surface.true,falsefalse
contoursBydoubleThe distance between the contours.Any double > 0.missing
contoursFromdoubleThe level at which the first contour should be plotted.Any double.missing (causes default scaling)
contoursTodoubleThe level at which the last contour should be plotted.Any double > contoursFrom.missing
contourTypeStringThe type of contours to be plotted."Lines",
"Regions"
"Regions"
gridSizeintThe number of values along each dimension of the matrix which defines the surface.2+21
xMaximumdoubleThe maximum value of X in the grid matrix.Any double > xMinimum.1.0
xMinimumdoubleThe minimum value of X in the grid matrix.Any double.0.0
xVariableNameStringThe name of the column with data values to be plotted (if any).Any string."X"
yMaximumdoubleThe maximum value of Y in the grid matrix.Any double > yMinimum.1.0
yMinimumdoubleThe minimum value of Y in the grid matrix.Any double.0.0
yVariableNameStringThe name of the column with data values to be plotted (if any).Any string."Y"

Other properties are inherited from the java.awt.Canvas class and from the general GraphicalStatbean class.

Code Sample

//create a datasource bean
FileDataSource fileDataSource1 = new STATBEANS.FileDataSource();

//set the file name to be read
fileDataSource1.setFileName("c:\\statbeans\\samples\\cardata.txt");

//create a plot bean
ContourPlot contourPlot1 = new STATBEANS.ContourPlot();

//set limits for the x and y dimensions
double xmin=0.0;
double xmax=10;
double ymin=0.0;
double ymax=20.0;
contourPlot1.setXMinimum(xmin);
contourPlot1.setXMaximum(xmax);
contourPlot1.setYMinimum(ymin);
contourPlot1.setYMaximum(ymax);

//set the number of points along each axis
int n=41;
contourPlot1.setGridSize(n);

//create a matrix with the height of the surface
double grid[][]=new double[n][n];
for(int i=0; i<n; i++)
{
double x=xmin+i*xmax/(n-1);
for(int j=0; j<n; j++)
{
double y=ymin+j*ymax/(n-1);
grid[i][j]=200.0+3*(x-5)*(x-5)-2*(y-10)*(y-10);
}
}
contourPlot1.setSurfaceGrid(grid);

//position the legend
contourPlot1.setLegendVerticalPosition(1.1);
contourPlot1.setLegendHorizontalPosition(1.1);

//add the plot to the application frame
add(contourPlot1);

//make the plot a listener for changes in the ProgramDataSource bean
programDataSource1.addDataChangeListener(contourPlot1.listenerForDataChange);

//notify all listeners
programDataSource1.updateListeners();