
You can reference the template for later scatter plots in the Options dialog of the Chart Builder when building the graph, or in the GGRAPH command as follows: The key points for this application is to check both "Optional lines" and "Legend display" in the :"Save Chart Template" dialog. You can find more details on saving and applying templates in the online help in SPSS Statistics at Help->Topics. Save a template from the File menu of the Chart Editor. After building a scatterplot, edit it in the Chart Editor and use the Elements menu in that editor to add the "Fit Line at Total" or "Fit Line at Subgroups" as appropriate for your graph. Building this template would require you to edit a scatterplot in the chart editor, but subsequent scatter plots could call the template in the GGRAPH command. It was noted in the first paragraph that a chart template could be built to add the R-squared value to the graph. The second ELEMENT subcommand requests separate fit lines in unique colors for the minority groups. The first ELEMENT subcommand assigns different colors to the observed data points, i.e., the scatter, for the different minority groups. Note the references to MINORITY in the GGRAPH variable list, the separate DATA subcommand for MINORITY, the GUIDE subcommand for MINORITY (which identifies it as a legend variable, and in the ELEMENT subcommands. GUIDE: legend(aesthetic(), label("Minority Status"))ĮLEMENT: point(position(edlevel*salnow), color(minority))ĮLEMENT: line(position(smooth.linear(edlevel*salnow)), color(minority)) GUIDE: axis(dim(2), label("Current Salary")) GRAPHDATASET NAME="graphdataset" VARIABLES=edlevel salnow minority MISSING=LISTWISE REPORTMISSING=NOĭATA: minority=col(source(s), name("minority"), unit.category()) The following GGRAPH and GPL commands will perform this task. Suppose that you wished to plot separate fit lines for cases on the basis of a categorical third variable, such as minority status (MINORITY). This added subcommand requests the fit line. These commands are produced by requesting a scatterplot for EDLEVEL (X axis) and SALNOW (Y axis) in the Chart Builder, pasting the command to a syntax window, then adding the subcommand: GUIDE: axis(dim(2), label("Current salary"))ĮLEMENT: line(position(smooth.linear(edlevel*salnow))) GUIDE: axis(dim(1), label("Educational level")) GRAPHDATASET NAME="graphdataset" VARIABLES=edlevel salnow MISSING=LISTWISE REPORTMISSING=NOĭATA: edlevel=col(source(s), name("edlevel"))ĭATA: salnow=col(source(s), name("salnow")) Here is an example GGRAPH and GPL command set to produce a scatterplot with a fit line. However, you can request a fit line in a GPL syntax subcommand, which still saves you from having to edit each chart in a chart editor to add the fit line. GGRAPH/GPL commands can be generated by the Graph>Chart Builder dialogs, but the dialogs don't have a feature to request a fit line in a scatterplot. This option is described in more detail below. GPL does not print the R-squared with the fit line, although a chart template could be devised to add this feature to the graphs. IGRAPH also places the R-squared value (squared multiple correlation) for the regression line to the right side of the scatterplot.

With one or more split file variables designated, either the IGRAPH or GGRAPH/GPL commands will produce a scatterplot for each split by running a single IGRAPH or GGRAPH/GPL command.

GGRAPH/GPL commands and Interactive Graphs (IGRAPH command) are the only graph procedures in SPSS that will let you request the regression fit line directly in the scatterplot dialogs or syntax command, so that you don't have to open the graph in a chart editor to add the fit line.
