[ Prev | Main | Next ]

ScatterPlotApplet



The ScatterPlotApplet draws a scatter plot of points (a,b), where the data is taken from an input table. The table is on the left side of the applet and can be edited by the user. By default, the applet will also show the regression line for the data and some statistics (the slope and y-intercept of the regression line and the correlation coefficient for the data). Each data point comes from one row in the table. Two input boxes at the bottom specify how the data points (a,b) are to be computed from the data. By default, a is just the entry in the first column of the table and b is the entry from the second column. However, a and b can be computed from other expressions, which can use the column names as variables. For example, it is possible to plot sqrt(X) versus Y. The special variable "rowNumber" can also be used in the expressions to represent the number of the row in the table.

When editing the table, the user can move among the cells of the table with the arrow keys, the tab key and the return key. A new row is added automatically when the user moves down from the last row of the table, provided that row is empty. An empty row at the bottom of the table is always completely ignored in the calculations for the scatter plot and regression line. Missing values are reported as errors, but it is possible to change this behavior with an applet param. Here is what the applet looks like when no applet params are specified:

Click the following button to open another version of the applet in a separate window. In this version, the input boxes have been removed and several sample files of data have been made available in a menu at the top of the window. When the user clicks the "Load File" button, a data file is loaded and its contents are used to replace the numbers currently in the table. Also -- just to show that it can be done -- the row numbers at the left of the data table and the column names at the top of the table have been removed.

This applet was created using the applet tag:

 <applet archive="webcompmath.jar" code="net.sourceforge.webcompmath.applets.ScatterPlotApplet" width=200 height=30>

<param name="UseExpressionInputs" value="no">

<param name="ShowRowNumbers" value="no">

<param name="ShowColumnTitles" value="no">

<param name="File1" value="Some sample data that almost lies along a line; AlmostLinearData.dat">

<param name="File2" value="Some randomly generated data; RandomData.dat">

<param name="File3" value="AlmostQuadraticData.dat">

</applet>

Here is a table of the applet parameters processed by ScatterPlotApplet. (Note that this is not a subclass of GenericGraphApplet, and it does not allow all the applet params defined in that class. These are the only parameters that ScatterPlotApplet understands.) Keep in mind that you have to get the name of the param exactly right, including the capitalization.

Param Name Type Default Description
ColumnName1 String X The name of the first column in the table. By default, this is displayed at the top of the column. If expression input boxes are used, this name must be a legal identifier so that it can be used in expressions.
ColumnName2 String Y The name of the second column in the table. By default, this is displayed at the top of the column. If expression input boxes are used, this name must be a legal identifier so that it can be used in expressions.
UseExpressionInputs yes/no yes Should the expression input boxes be available?
ShowStats yes/no yes Should the slope of the regression line, the intercept of the regression line, and the correlation coefficient be displayed?
ShowColumnTitles yes/no yes Should column names be shown as titles at the top of the columns in the data table?
ShowRowNumbers yes/no yes Should row numbers be shown along the left edge of the data table?
ShowRegressionLine yes/no yes Should a regression line be drawn for the plotted data points?
MissingValueIsError yes/no yes Should a missing value be treated as an error? Note that an empty line at the bottom of the data table is always ignored and is never treated as an error. A cell that contains a string that does not represent a legal real number is always treated as an error. The question is, what should happen when an empty cell is found (other than in a last, empty row), and what should happen when the value of an expression such as sqrt(X) is undefined for some row of the table? If MissingValueIsError is true, these cases will be treated as errors and an error message will be displayed. If MissingValueIsError is false, then these cases will just be ignored and calculations will be based only on the rows that do not have empty cells or undefined expression values.
FrameTitle String Scatter Plots The title in the title bar of the window, when the applet is shown as a separate window.
PanelTitle String (none) If a Panel Title is provided and the applet runs on the Web page rather than in a separate window, and there is no menu of sample data files, then the PanelTitle is displayed as a title at the top of the applet.
LaunchButtonName String (none) If this is defined, then the applet will have its own window and only a button will appear on the Web page. The value of the param gives the label for that button. A separate window is also used even if this param is not defined but the height in the applet tag is less than or equal to 50. In this case, the label of the button is "Launch" followed by the value of the FrameTitle param. The size of the window is determined by its contents.
File,
File1,
File2,
...
String (none) These params specify sample data files that will be available for the user to load. You can use the "File1" param whether or not there is a "File" param. However, if you want to use "File2", you must also use "File1"; if you want to use "File3", you must also use "File2"; and so on. The value of the param specifies the name of the file and, optionally, a menu entry for the menu. If the value contains a ";", then the part before the ";" is shown in the menu and the part after the ";" is the name of the file. If the value does not contain a ";", then the entire value is the name of the file, and this file name also appears in the menu. The file must be on the Web server in the same directory as the source file of the Web page that contains the applet.
FontSize int > 0 (see discussion) This sets the font size for all user interface elements in the applet. If it is absent, then the defaults for the Java Swing look and feel are used, which are mostly 12 points (although some are smaller).


[ Prev | Main | Next ]