PSPP Graphics: Examples and Notes

PSPP has limited built‑in graphics, so this page shows how to create plots from PSPP data using both PSPP syntax and external tools such as GNUPLOT. These examples include residual plots and other diagnostics commonly used in regression analysis. Also other types of plots PSPP can make for other purposes.


How to Make a Scatterplot of predicted vs residuals.

Here is an example of plotting residuals and predicted values from a linear regression. Residuals should be more or less randomly distributed. There should not be patterns in residuals. That's what you are looking for.

Scatterplots can be found in the PSPPIRE Data Editor menu Graphs-> Scatterplot and the psppire Scatterplot options window.

scatter plot menu in psppire

Data:

          Data List
╭─────┬────┬────┬────┬─────╮
│  y  │ x1 │ x2 │RES1│PRED1│
├─────┼────┼────┼────┼─────┤
│10.00│1.00│4.10│-.20│10.20│
│12.00│2.00│5.00│ .20│11.80│
│13.00│3.00│6.20│-.07│13.07│
│15.00│4.00│7.10│ .33│14.67│
│16.00│5.00│8.00│-.27│16.27│
╰─────┴────┴────┴────┴─────╯

Code:

** Use regression output variables (pred and resid) to check data.
GRAPH
  /SCATTERPLOT = pred1 WITH res1.

Output:

scatterplot of predicted vs residual

All we see is a cloud of points and there is no trend or pattern. This is what we'd like to see from residuals: a random scatter with no pattern. With only 5 points, the plot is naturally sparse, but it still shows no systematic pattern (but note it's easy to be fooled by a few points).

Note: psppire outputs the entire output window, not individual plots. One way to save a plot for documentation or reports, is to use your system’s screenshot tool to capture just the graphic from the Output window.

Note: PSPP accepts the SPSS BIVAR keyword in scatterplots for compatibility, but it has no effect on the plot. PSPP always produces a simple bivariate scatterplot.

See Also: PSPP Inferential and Modeling Procedures which has the Linear Regression that produced this plot data.

How to Make a Histogram with PSPP

PSPP produces other types of plots, including histograms and bar charts. The next example is the histogram. This will be produced with a normal curve superimposed on the histogram. While this feature is not given in the documentation as an option to the HISTOGRAM graph subcommand, it nonetheless produces the desired result. This uses the Auto-MPG dataset.

Code

GET FILE="regression2.sav".
GRAPH /HISTOGRAM (NORMAL) = mpg.

Output

      Statistics
+---------+---------+
|         |cylinders|
+---------+---------+
|N Valid  |      392|
|  Missing|        0|  
+---------+---------+
|Mean     |     5.47|
+---------+---------+
|Std Dev  |     1.71|
+---------+---------+
|Minimum  |        3|  
+---------+---------+
|Maximum  |        8|  
+---------+---------+

                          cylinders
+-------+---------+-------+-------------+------------------+
|       |Frequency|Percent|Valid Percent|Cumulative Percent|
+-------+---------+-------+-------------+------------------+
|Valid 3|        4|   1.0%|         1.0%|              1.0%|
|      4|      199|  50.8%|        50.8%|             51.8%|
|      5|        3|    .8%|          .8%|             52.6%|
|      6|       83|  21.2%|        21.2%|             73.7%|
|      8|      103|  26.3%|        26.3%|            100.0%|
+-------+---------+-------+-------------+------------------+
|Total  |      392| 100.0%|             |                  |   
+-------+---------+-------+-------------+------------------+

See piechart-1.png for a chart.                               
histogram with normal curve

To produce the plot without the normal curve, remove the "(NORMAL)" from the GRAPH command.

The PSPP GUI (psppire) can do histograms. There is a checkbox for the normal curve on the Histogram input screen. See Graphs->Histogram and the psppire Analyze->Descriptive Statistics->Frequencies->Charts options menu.

psppire Frequencies Charts menu

How to Make a Bar Chart with PSPP

Here is an example of a bar chart of the number of cylinders in the engines of the cars from the auto-mpg dataset. You can see that 4-cylinder engines are the most popular. 3-cylinder engines are used by American automakers including Chevrolet, Buick, and Ford, as well as Nissan and Toyota even in 2026. 5-cylinder engines are also still used by some manufacturers such as Acura, Audi, Ford, Toyota, Fiat, Chevrolet, and others. 6- and 8-cylinder cars follow 4-cylinder cars in popularity.

Code

GRAPH
  /BAR = COUNT by cylinders.

Output

bar chart of cylinder counts in cars

In psppire, the barchart settings can be found in the Graphs->Histogram and the psppire Analyze->Descriptive Statistics->Frequencies->Charts options menu.

psppire Frequencies Charts menu

Creating a Pie Chart with PSPP's FREQUENCIES Procedure

This example will use the auto-mpg data set again. For the pie chart the cylinders variable will be plotted. Cylinders are limited, so make a good choice for a pie chart. If there had been many values, the pie chart would get very crowded with small wedges and not be very useful.

In psppire, the Piechart can be found at Analyze->Descriptive Statistics->Frequencies->Charts on the Charts menu

piechart in frequency Charts menu.

Code

GET FILE="regression2.sav".

DISPLAY DICTIONARY.

FREQUENCIES VARIABLES = cylinders
   /PIECHART. 
      Statistics
+---------+---------+
|         |cylinders|
+---------+---------+
|N Valid  |      392|
|  Missing|        0|
+---------+---------+
|Mean     |     5.47|
+---------+---------+
|Std Dev  |     1.71|
+---------+---------+
|Minimum  |        3|
+---------+---------+
|Maximum  |        8|
+---------+---------+

                          cylinders
+-------+---------+-------+-------------+------------------+
|       |Frequency|Percent|Valid Percent|Cumulative Percent|
+-------+---------+-------+-------------+------------------+
|Valid 3|        4|   1.0%|         1.0%|              1.0%|
|      4|      199|  50.8%|        50.8%|             51.8%|
|      5|        3|    .8%|          .8%|             52.6%|
|      6|       83|  21.2%|        21.2%|             73.7%|
|      8|      103|  26.3%|        26.3%|            100.0%|
+-------+---------+-------+-------------+------------------+
|Total  |      392| 100.0%|             |                  |
+-------+---------+-------+-------------+------------------+
See piechart-1.png for a chart.

Output

piechart from pspp frequencies procedure

4-cylinder cars outnumber 6- and 8-cylinder cars in this dataset. This is plain from looking at the pie chart.

Creating a Boxplot with PSPP's EXAMINE Procedure

This example will again use the auto-mpg data. The box plot will be done for the mpg variable, which is the dependent variable in the regression we did earlier with the auto-mpg data.

Code

GET FILE="regression2.sav".

DISPLAY DICTIONARY.

EXAMINE VARIABLES = mpg
   /PLOT BOXPLOT.

EXAMINE VARIABLES = mpg by cylinders
   /PLOT BOXPLOT.

Output

        Case Processing Summary
+---+---------------------------------+
|   |              Cases              |
|   +-----------+---------+-----------+
|   |   Valid   | Missing |   Total   |
|   +---+-------+-+-------+---+-------+
|   | N |Percent|N|Percent| N |Percent|
+---+---+-------+-+-------+---+-------+
|mpg|392| 100.0%|0|    .0%|392| 100.0%|
+---+---+-------+-+-------+---+-------+

See boxplot-1.png for a chart.

      Tests of Normality
+---+-----------------------+
|   |      Shapiro-Wilk     |
|   +---------+---+---------+
|   |Statistic| df|   Sig.  |
+---+---------+---+---------+
|mpg|      .97|392|1.05E-007|
+---+---------+---+---------+

             Case Processing Summary
+-------------+---------------------------------+
|             |              Cases              |
|             +-----------+---------+-----------+
|             |   Valid   | Missing |   Total   |
|             +---+-------+-+-------+---+-------+
|    cylinders| N |Percent|N|Percent| N |Percent|
+-------------+---+-------+-+-------+---+-------+
|mpg 3        |  4| 100.0%|0|    .0%|  4| 100.0%|
|    4        |199| 100.0%|0|    .0%|199| 100.0%|
|    5        |  3| 100.0%|0|    .0%|  3| 100.0%|
|    6        | 83| 100.0%|0|    .0%| 83| 100.0%|
|    8        |103| 100.0%|0|    .0%|103| 100.0%|
+-------------+---+-------+-+-------+---+-------+

See boxplot-2.png for a chart.

           Tests of Normality
+-------------+-----------------------+
|             |      Shapiro-Wilk     |
|             +---------+---+---------+
|    cylinders|Statistic| df|   Sig.  |
+-------------+---------+---+---------+
|mpg 3        | 1.4E+012|  4|      NaN|
|    4        |      .98|199|      .00|
|    5        |      .92|  3|      .44|
|    6        |      .82| 83|1.37E-008|
|    8        |      .92|103|1.90E-005|
+-------------+---------+---+---------+

Boxplot of MPG

boxplot of mpg via pspp EXAMINE procedure

Boxplot of MPG by Cylinders

boxplot of mpg by cylinders via pspp EXAMINE procedure

The boxplot of mpg shows that the mpg variable has no outliers, since PSPP marks outliers with circles and none appear. The median line is near the center of the box, indicating that the middle 50% of the data is fairly symmetric. The whiskers extend to the minimum and maximum values without being excessively long, suggesting a moderate spread. The Shapiro–Wilk test confirms that mpg is not normally distributed, which is typical for real‑world fuel economy data.

However, the cylinders data does have outliers.

Boxplot of Horsepower

boxplot of horsepower via pspp EXAMINE procedure

The horsepower boxplot shows how pspp plots outliers in a variable. This variable has many outliers that should be investigated. The data are highly skewed. Perhaps a transformation is needed. Or maybe the data need correction (e.g. data entry error). These are decisions for the data analyst.

Workflow Tip: This boxplot is doing what it was designed to do: showing the odd or extreme values in the variable. It does not mean these values should be dropped from the boxplot or otherwise covered up in the presentation. They should be investigated and explained.

Further Graphing with GNUPLOT using PSPP Data

Gnuplot is a free plotting program. It can be used on Windows and Linux/Unix to produce plots. See: Gnuplot Demos and Gnuplot Documentation.

Gnuplot began in 1986, and is under current development. It is very good if you need to reproduce a plot regularly because the plotting can be scripted and rerun.

You don't need gnuplot specially. It's an example of using PSPP-generated data in another application. Use whatever graphing program you prefer. Most can read CSV data.

Saving the linear regression residuals and predicted values as CSV data from the PSPP REGRESSION procedure allows us to get the data into gnuplot easily as a CSV file.

Gnuplot Residuals Plot Program

Raw Data

          Data List
╭─────┬────┬────┬────┬─────╮
│  y  │ x1 │ x2 │RES1│PRED1│
├─────┼────┼────┼────┼─────┤
│10.00│1.00│4.10│-.20│10.20│
│12.00│2.00│5.00│ .20│11.80│
│13.00│3.00│6.20│-.07│13.07│
│15.00│4.00│7.10│ .33│14.67│
│16.00│5.00│8.00│-.27│16.27│
╰─────┴────┴────┴────┴─────╯

CSV file used by gnuplot

y,x1,x2,RES1,PRED1
10,1,4.1,-0.20000000000000284,10.200000000000003
12,2,5,0.20000000000027285,11.799999999999727
13,3,6.2,-0.06666666666703058,13.06666666666703
15,4,7.1,0.33333333333324333,14.666666666666757
16,5,8,-0.266666666666481,16.26666666666648

Program

set datafile separator ","                                                                                              

set terminal pngcairo size 400,400
set output "C:/pspp/residuals2.png"
unset key

set xlabel "Predicted"
set ylabel "Residuals"
set title "Residuals vs Predicted Values"

plot "C:/pspp/regression.csv" using 5:4 every ::1 with points pt 7 ps 1.2 lc rgb "#3366cc" title "Residuals"

This reads the 4th and 5th variables from the CSV file (Residuals on the Y-axis and Predicted on the X-axis). The rgb setting sets the point color, and set title sets the plot title. You can adjust the plot size on the set terminal line. The every ::1 option skips the first line of the CSV file. every is a row selector. The remaining options set the point size, point type, color.

Note, by default, gnuplot puts in an extra plot point to show what the plot symbol is. unset key will remove that point.

The resulting plot looks like this:

scatterplot of predicted vs residual from gnuplot

A Q–Q plot compares the sample residuals to the theoretical normal distribution. If the residuals follow a straight line, they are approximately normal. Curvature or S‑shapes indicate departures from normality.

Gnuplot Code

set datafile separator ","
set terminal pngcairo size 800,600
set output "C:/pspp/qqplot.png"
unset key

set xlabel "Theoretical Quantiles"
set ylabel "Sample Residuals"
set title "Normal Q-Q Plot of Residuals"

stats "C:/pspp/regression.csv" using 4 nooutput

# Safe row number function for CSV files
row(n) = n + 1

plot "C:/pspp/regression.csv" using \
    (invnorm((row($0) - 0.5) / STATS_records)):4 every ::1 \
    with points pt 7 ps 1.2 lc rgb "#3366cc"

Output

Q-Q plot for small regression example Since this was a small regression example, the plot doesn't show many points.

Using PSPP's EXAMINE Command for Normality Diagnostic Plots

PSPP's EXAMINE command has a /PLOT subcommand that can generate several diagnostic graphs, including a Normal Q-Q plot and a spread-level plot which PSPP labels as a detrended normal Q-Q plot by pspp. It also includes Shapiro-Wilk statistic output, which is commonly used to test normality.

This example will use the Auto-MPG data with n=392 to provide enough observations for clear disagnostic plots.

Code

GET FILE="regression2.sav".

LIST.

EXAMINE 
  /VARIABLES=res1
  /PLOT NPPLOT
  /PLOT SPREADLEVEL.

Note: because I wanted to save the plots for use in this page, I ran this example from a unix command line using command line pspp. psppire will also work, but getting the graphics out is a few more steps. EXAMINE gives a case summary first. This program is reading the residuals (RES1) from the regression model. n=392 is correct and there are no missing values, which is expected.

Output

         Case Processing Summary
+----+---------------------------------+
|    |              Cases              |   
|    +-----------+---------+-----------+
|    |   Valid   | Missing |   Total   |   
|    +---+-------+-+-------+---+-------+
|    | N |Percent|N|Percent| N |Percent|
+----+---+-------+-+-------+---+-------+
|RES1|392| 100.0%|0|    .0%|392| 100.0%|
+----+---+-------+-+-------+---+-------+

The two plots produced are noted next. They are the Q-Q plot and the detrended Q-Q plot.

Q-Q plot of the residuals.

examine5-1.png

pspp calls the Q-Q plot the npplot type in EXAMINE.

De-trended Q-Q plot of the residuals.

examine5-2.png

The de-trended Q-Q plot is often more informative than the standard Q-Q plot because it displays deviations from normality directly, without the diagonal reference line that can visually mask systematic departures. pspp calls this the spreadlevel plot in EXAMINE.

The de-trended Q-Q plot above shows an issue with normality. The data are obviously skewed. Whether this is enough to bias your model is a judgment you'll need to make, and that judgment gets easier as you get more experience with data.

If your dependent variable is strongly skewed, your instructor or boss may recommend a transformation (for example, a log or Box–Cox). PSPP can compute transformed variables using COMPUTE before running the analysis.

Finally, the Shapiro-Wilk test of normality result is given. In this case, the test statistic is .97 and p-value is 1.72E-006, which is tiny and much less then .05. Therefore we rejected the null hypothesis that the residuals are normally-distributed. Statistically this indicates non-normality.

      Tests of Normality
+----+-----------------------+
|    |      Shapiro-Wilk     |   
|    +---------+---+---------+
|    |Statistic| df|   Sig.  |
+----+---------+---+---------+
|RES1|      .97|392|1.72E-006|
+----+---------+---+---------+

Three Panel Gnuplot Diagnostics

This example creates 3 diagnostic plots and then combines them into a three-panel layout. The three plots are: a normal Q-Q plot, a plot of residuals vs. predicted values, and a scale-location plot. It also uses the Auto-MPG data set which gives us 392 points to plot.

Code

set datafile separator ","
set terminal pngcairo size 1200,900
set output "diagnostics3.png"

set multiplot layout 3,1 title "Regression Diagnostics"

##############################
# 1. Normal Q-Q Plot
##############################
set xlabel "Theoretical Quantiles"
set ylabel "Sample Residuals"
set title "Normal Q-Q Plot"
unset key

stats "regression2.csv" using 10 nooutput
row(n) = n + 1

plot "regression2.csv" using \
    (invnorm((row($0) - 0.5) / STATS_records)):10 every ::1 \
    with points pt 7 ps 1.2 lc rgb "#3366cc"

##############################
# 2. Residuals vs Predicted
##############################
set xlabel "Predicted Values"
set ylabel "Residuals"
set title "Residuals vs Predicted"
unset key

plot "regression2.csv" using 11:10 \
    with points pt 7 ps 1 lc rgb "#cc6633"

##############################
# 3. Scale-Location Plot
##############################
set xlabel "Predicted Values"
set ylabel "Sqrt(|Residual|)"
set title "Scale-Location Plot"
unset key

plot "regression2.csv" using 11:(sqrt(abs($10))) \
    with points pt 7 ps 1 lc rgb "#669933"

unset multiplot

Output

3-panel Diagnostics 3 panel diagnostics

Residuals vs Predicted Values with a Smoothed Bezier Line

This uses the auto-mpg data set with residuals and predicted values from the regression example in pspp_analysis2.html

Code

set datafile separator ","
set xlabel "Predicted (PRED1)"
set ylabel "Residuals (RES1)"
set title "Residuals vs Predicted (with Smooth Bezier smooth)"
set terminal pngcairo size 1200,900
set output "respred2.png"
unset key
plot "regression2.csv" using 11:10 with points pt 7 lc rgb "blue", \
     "" using 11:10 smooth sbezier lc rgb "red" lw 2

Output

Residuals vs Predicted with Smoothed Bezier Line

residuals vs predicted with smooth bezier line

The smooth bezier line shows the skew in the data.


If you have suggestions, comments, or corrections, you can open an issue on the Github repository Issues list