XYPlot STATBEAN®



Purpose: An XY chart maker that displays a scatterplot or line plot for two numeric columns.

Scatter Plot Graph Maker DataSource: any. 

xyplotexample


XY Chart Maker Read/Write Properties
Name Type Description Possible Values Default Value
connected boolean Whether the points should be connected with a line. true,false false
forceEqualScales boolean Whether to force the x-axis and y-axis scaling to be the same. true,false false
points boolean Whether point symbols should be plotted. true,false true
referenceLine String Type of reference line, if any, to be added to the plot. "None",
"Horizontal",
"Vertical",
"Diagonal"
"None"
referenceLineColor Color Color for drawing the reference line. Any valid color. Color.black
referenceLineLocation double Location of a horizontal or vertical reference line. Any double value. 0.0
smootherColor Color Color for drawing the smooth. Any valid color. Color.blue
smootherPercentage int Width of the smoother as a percentage of the number of observations. 1-99 50
smootherType String Type of smoother, if any, to be added to the plot. "None",
"Running Means",
"Running Lines",
"LOWESS",
"Robust LOWESS"
"None"
suppressXaxis boolean Whether to suppress display of the x-axis scaling and ticmarks. true,false false
suppressYaxis boolean Whether to suppress display of the y-axis scaling and ticmarks. true,false false
tablewiseExclusion boolean Whether all rows of the data table containing a missing value in any column should be excluded from the plot. true,false false
xVariableName String The name of the column with data values to be plotted on the horizontal axis. Any string. "X"
yVariableName String The name of the column with data values to be plotted on the vertical axis. Any string. "Y"

Other properties needed for the scatter plot graph maker 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();