Boxplots in SPSS

Cheatsheet

Published

July 17, 2024

This work was developed using resources that are available under a Creative Commons Attribution 4.0 International License, made available on the SOLES Open Educational Resources repository by the School of Life and Environmental Sciences, The University of Sydney.

About

The boxplot is a visual representation of a dataset’s distribution, showing the median, quartiles, and outliers. It is useful for comparing distributions between groups and identifying outliers within a single group.

  • You have SPSS installed, ideally version 28.0 or later.
  • You can follow instructions to select, click and drag elements in SPSS.

Your data should be structured in a way that makes it easy to plot. The ideal structure is long, i.e. one where each column represents a variable and each row an observation (Figure 1). You can either reshape your data in R or move cells manually in a spreadsheet program to achieve the desired structure. For boxplots comparing more than one group of data, a categorical variable representing the group should be present in the data.

Figure 1: Long data (left) where each column is a different variable – e.g. Sex is categorical and BW is the measured, continuous response – is preferred over wide data (right), as it makes it easier to manipulate data when plotting.

1 Data

For this cheatsheet we will use part of the possums dataset used in BIOL2022 labs.

2 Import data

Open SPSS and import the data file:

  • File > Open > Data...
  • Select the downloaded file possum_bw.xlsx
  • Check that the data is correctly identified( Figure 2) and click OK
Figure 2: Before importing your file, make your selections and look at the preview window to ensure the data is correctly identified.

3 Plot

  1. Go to Graphs > Chart Builder...
    • If a warning box appears on “measurement level”, click OK (should be safe to ignore and you can fix issues later).
  2. Select boxplot from the gallery at the bottom of the window.
  3. Drag the boxplot icon to the canvas.
  4. Drag the variable Sex to the X-Axis box.
  5. Drag the variable BW to the Y-Axis box.
  6. Click OK to generate the plot.
Figure 3: Boxplot in SPSS

4 Chart Editor

To make changes to the plot, double-click on the plot to open the Chart Editor (Figure 4). Here you can make changes to the plot, such as:

  • Titles: Click on the title to edit it.
  • Axis labels: Click on the axis labels to edit them.
  • Colours: Click on the elements you want to change and select a new colour.
  • Outliers: Click on the outliers to select them and change their appearance.
  • Error bars: Click on the error bars to change their appearance.
  • Legend: Click on the legend to change its appearance.

You get the idea! Almost anything you click on can be edited. Play around with the options to customise your plot.

Figure 4: Chart Editor in SPSS. Most elements of the plot can be edited by clicking on them.

5 More resources