StatBean Name: XYPlot

Purpose: Displays a scatterplot or lineplot for two numeric columns.

DataSource: any.


Read/Write Properties
NameTypeDescriptionPossible ValuesDefault Value
connectedbooleanWhether the points should be connected with a line.true,falsefalse
forceEqualScalesbooleanWhether to force the x-axis and y-axis scaling to be the same.true,falsefalse
pointsbooleanWhether point symbols should be plotted.true,falsetrue
referenceLineStringType of reference line, if any, to be added to the plot."None",
"Horizontal",
"Vertical",
"Diagonal"
"None"
referenceLineColorColorColor for drawing the reference line.Any valid color.Color.black
referenceLineLocationdoubleLocation of a horizontal or vertical reference line.Any double value.0.0
smootherColorColorColor for drawing the smooth.Any valid color.Color.blue
smootherPercentageintWidth of the smoother as a percentage of the number of observations.1-9950
smootherTypeStringType of smoother, if any, to be added to the plot."None",
"Running Means",
"Running Lines",
"LOWESS",
"Robust LOWESS"
"None"
suppressXaxisbooleanWhether to suppress display of the x-axis scaling and ticmarks.true,falsefalse
suppressYaxisbooleanWhether to suppress display of the y-axis scaling and ticmarks.true,falsefalse
tablewiseExclusionbooleanWhether all rows of the data table containing a missing value in any column should be excluded from the plot.true,falsefalse
xVariableNameStringThe name of the column with data values to be plotted on the horizontal axis.Any string."X"
yVariableNameStringThe name of the column with data values to be plotted on the vertical axis.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");

//set the delimiter character used in the file
fileDataSource1.setDelimiter("tab");

//create a plot bean
XYPlot xYPlot1 = new STATBEANS.XYPlot();

//set the columns for the x and y axes
xYPlot1.setYVariableName("mpg");
xYPlot1.setXVariableName("weight");

//override default scaling
xYPlot1.setUseDefaultScaling(false);

//set scaling for x-axis
xYPlot1.setXaxisFrom(1500.0);
xYPlot1.setXaxisTo(4500.0);
xYPlot1.setXaxisBy(1000.0);

//set scaling for y-axis
xYPlot1.setYaxisFrom(10.0);
xYPlot1.setYaxisTo(50.0);
xYPlot1.setYaxisBy(10.0);

//add a smoother
xYPlot1.setSmootherType("Robust LOWESS");

//override the top title
xYPlot1.setTopTitleLine1("Plot of Automobile Data");

//override the xaxis title
xYPlot1.setXaxisTitle("weight in pounds");

//turn on point identifcation
xYPlot1.setHighlightPointOnMouseClick(true);
xYPlot1.setShowPointClickedMessage(true);

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

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

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