StatBean Name: SurfacePlot

Purpose: Creates 3D surface 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 in the base."Lines",
"Regions"
"Regions"
drawContoursBelowbooleanWhether to draw contours in the base of the base.true,falsefalse
gridSizeintThe number of values along each dimension of the matrix which defines the surface.2+21
horizontalViewAngleintAngle from which plot is viewed in degrees.Any integer.20
surfaceGriddouble[gridSize][gridSize]An array containing the height of the surface.Any double.none
surfaceTypeStringThe type of surface to be plotted."Wireframe",
"Solid",
"Contoured"
"Wireframe"
threeDReferenceLineSbooleanWhether to add lines from plotted points to the surface.true,falsetrue
threeDReferenceLineColorColorColor for drawing the reference lines to the surface.Any valid color.Color.black
verticalViewAngleintAngle from which plot is viewed in degrees.Any integer.20
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"
zVariableNameStringThe name of the column with data values to be plotted (if any).Any string."Z"

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
SurfacePlot surfacePlot1 = new STATBEANS.SurfacePlot();

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

//set the number of points along each axis
int n=11;
surfacePlot1.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]=47.75-0.0065*x-0.0467*y;
}
}
surfacePlot1.setSurfaceGrid(grid);

//set the surface type to contoured
surfacePlot1.setSurfaceType("Contoured");

//add point to the plot
surfacePlot1.setZVariableName("mpg");
surfacePlot1.setXVariableName("weight");
surfacePlot1.setYVariableName("horsepower");
surfacePlot1.setAddPoints(true);

//position the legend
surfacePlot1.setLegendVerticalPosition(1.3);
surfacePlot1.setLegendHorizontalPosition(1.0);

//don't show powers on the x-axis
surfacePlot1.setXaxisPower(false);

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

//make the plot a listener for changes in the FileDataSource bean
fileDataSource1.addDataChangeListener(surfacePlot1.listenerForDataChange);

//instruct the fileDataSource bean to read the file
fileDataSource1.readData();