3.9 SPSS Lab 9: Visualisation

This tutorial by Dr Hangyoung Lee, adapted to this website by Nicholas Harrigan.

Introduction

In this tutorial we cover techniques for drawing a number of useful graphics.

Visualising variables provide an important “first look” at your data.

The dataset used in this tutorial can be downloaded from here.

1. Producing a Pie Chart

A pie chart is a circular graph with slices that represent the proportion of the total contained within each category.

We can use pie charts to visualise nominal as well as ordinal variables.

To produce a pie chart, go to Analyze > Descriptive Statistics > Frequencies.

Analyze > Descriptive Statistics > Frequencies

Figure 1: Analyze > Descriptive Statistics > Frequencies

In the popped-up box, select a variable for which you want to produce a pie chart and then click the arrow. In this example, I will produce a pie chart of gender.

Select a variable for which you want to produce a pie chart

Figure 2: Select a variable for which you want to produce a pie chart

Now, you will see the selected variable in the pane of Variable(s). Click Charts.

Click Charts

Figure 3: Click Charts

In the popped-up box, select “Pie charts” as Chart Type and “Frequencies” as Chart Values. Then click Continue.

Select Pie charts as Chart Type and Frequencies as Chart Values

Figure 4: Select Pie charts as Chart Type and Frequencies as Chart Values

You will be back to the previous Frequencies box. Click OK.

Click OK

Figure 5: Click OK

In the output window, you will see the frequency table and pie chart of gender.

Pie chart of gender

Figure 6: Pie chart of gender

However, this pie chart does not provide information on the number (frequency) of males and females. Let’s add this information to the chart. At any place in the pie chart, right-click and then choose Edit Content > In Separate Window.

At any place in the pie chart, right-click and then choose Edit Content > In Separate Window.

Figure 7: At any place in the pie chart, right-click and then choose Edit Content > In Separate Window.

In the popped-up window, click the icon of Data Label Mode (see Figure 7). Then, move your mouse cursor to a place where you want to put the number. And click. You need to click on both green (female) and blue (male) areas. Then, you will see the frequency of male and female category.

See the frequency of male and female category

Figure 8: See the frequency of male and female category

In Figure 8, the size of numbers is too small. Let’s edit the font size for better readability. Click the icon of Data Label Mode again to turn off the data label mode and to go back to edit mode. You will see a popped-up window called properties. Close that.

Click the icon of Data Label Mode again to turn off the data label mode and to go back to edit mode. You will see a popped-up window called properties. Close that.

Figure 9: Click the icon of Data Label Mode again to turn off the data label mode and to go back to edit mode. You will see a popped-up window called properties. Close that.

Then, click any of the numbers (frequencies) on the pie chart. You will see the toolbar of font type and font size activated (see Figure 10). There you can change the size of font as well as the type. Let’s choose 12 as font size. Then close the Chart Editor by clicking X.

Click any of the numbers (frequencies) on the pie chart.

Figure 10: Click any of the numbers (frequencies) on the pie chart.

Note) In Figure 4, if you select “Percentages” as Chart Values (see Figure 11), the pie chart will show the percentage of each category of gender (see Figure 12).

Select Percentages

Figure 11: Select Percentages

Notice how chart now shows percentage of each gender in your sample.

Figure 12: Notice how chart now shows percentage of each gender in your sample.

2. Producing a Bar Chart

A bar chart (also called bar graph) is a graphical display of data using bars of different heights. We can use bar charts to visualise nominal as well as ordinal variables.

2.1 Bar charts with y-axis as frequency

The Frequencies command will produce a bar chart as well. Go to Analyze > Descriptive Statistics > Frequencies.

Analyze > Descriptive Statistics > Frequencies

Figure 13: Analyze > Descriptive Statistics > Frequencies

In the popped-up box, select a variable for which you want to produce a bar graph and then click the arrow. In this example, I will produce a bar graph of gender.

Select a variable for which you want to produce a bar graph and then click the arrow.

Figure 14: Select a variable for which you want to produce a bar graph and then click the arrow.

Now, you will see the selected variable in the pane of Variable(s). Click Charts.

Click Charts.

Figure 15: Click Charts.

In the popped-up box, select “Bar charts” as Chart Type and “Frequencies” as Chart Values. Then click Continue.

select Bar charts as Chart Type and Frequencies as Chart Values.

Figure 16: select Bar charts as Chart Type and Frequencies as Chart Values.

You will be back to the previous Frequencies box. Click OK.

Click OK.

Figure 17: Click OK.

In the output window, you will see the frequency table and bar chart of gender.

Bar chart of gender

Figure 18: Bar chart of gender

The bar chart consists of a Y-axis, representing the frequency, and an X-axis, representing each category of gender.

2.2 Bar charts with y-axis as percentage

Sometimes it is useful to compare the percentages of each category in a bar chart instead of frequencies. Let’s make A bar chart with a Y-axis representing the percentage. Follow the same steps from Figure 1 to Figure 3. Then, select “Percentages” as Chart Values. Then, click Continue.

Then, select Percentages as Chart Values. Then, click Continue.

Figure 19: Then, select Percentages as Chart Values. Then, click Continue.

In the box of Frequencies, click OK (see Figure 15). You will see the bar chart with a Y-axis representing the frequency of each gender category.

You will see the bar chart with a Y-axis representing the frequency of each gender category.

Figure 20: You will see the bar chart with a Y-axis representing the frequency of each gender category.

3. Producing a grouped bar chart

Suppose you want to compare the frequency of a variable by subgroups. For example, you may be interested in knowing how the distribution of political orientation differs by gender.

Bar charts can be used for this more complex comparison of data by grouping or stacking bar charts. Let’s examine grouped bar chart first.

A grouped bar graph produces bars for every combination of categories (gender X political orientation) and then group those bars by subgroups (gender), typically uing colored bars to represent a particular grouping.

To produce this grouped bar chart, go to Graphs>Legacy Dialogs > Bar.

Graphs>Legacy Dialogs>Bar

Figure 21: Graphs>Legacy Dialogs>Bar

In the popped-up window, choose “Clustered” as a type of bar charts and “Summaries for groups of cases” in Data in Chart Are. Then, click Define.

Choose Clustered as a type of bar charts.

Figure 22: Choose Clustered as a type of bar charts.

In the popped-up window,

  1. choose a variable for which a bar is produced (in our example, it is political orientation) in the pane of variables, and then click the arrow in Category Axis;
  2. choose a group variable by which bars are compared (in our example, it is gender), and then click the arrow in Define Clusters by;
  3. choose “% of cases” in Bars Represent (comparing the percentages makes more sense because the number of males and females is different) and then the bars will represent the percentages (If you choose “N of cases”, the bar will represent the frequency);
  4. click OK.
Choose a variable, and a grouping variable.

Figure 23: Choose a variable, and a grouping variable.

In the output window, you will see Figure 24.

Grouped bar chart

Figure 24: Grouped bar chart

You can add the percentages to this chart by following the same steps as you did for the pie chart.

Grouped bar chart with percentages.

Figure 25: Grouped bar chart with percentages.

4. Producing a stacked bar chart

A stacked bar chart provides an alternative way to compare the frequency of a variable by subgroups. In a stacked bar chart, parts of the data are stacked: each bar displays a total amount, broken down into sub-amounts. We will again compare the distribution of political orientation by gender. To produce it, Go to Graphs > Chart Builder.

Graphs > Chart Builder.

Figure 26: Graphs > Chart Builder.

In the popped-up window, tick the box of Don’t show this dialogue again and click OK.

Tick the box of Don't show this dialogue again.

Figure 27: Tick the box of Don’t show this dialogue again.

In the window of Chart Builder, click the icon of stacked bar chart. Drag and drop it to the upper white pane (see Figure 28).

Drag and drop the icon of stacked bar chart.

Figure 28: Drag and drop the icon of stacked bar chart.

Then, drag and drop gender to X-axis and political orientation to Stack: set color. After that, click Element Properties

Drag and drop gender to X-axis and political orientation to Stack: set color.

Figure 29: Drag and drop gender to X-axis and political orientation to Stack: set color.

Next, in the window of Element Properties, let’s edit properties of Bar1 by selecting “Percentage(?)” in Statistic. Then, click Apply.

Select percentage in statistic

Figure 30: Select percentage in statistic

You will see Set Parameters activated (see Figure 31). Let’s open that box and select “Total for Each X-Axis Category” as Denominator for Computing Percentage. This is to calculate percentages within subgroups by choosing the total counts of subgroup as denominator (instead of the total counts of your sample, or grand total). This way, each group has 100% as total percentage so meaningful comparison can be made. Click Continue. Then click Apply at the bottom.

Choosing the correct denominator for computing percentage.

Figure 31: Choosing the correct denominator for computing percentage.

Lastly, click OK to finish the Chart Builder.

Click OK to finish with Chart Builder

Figure 32: Click OK to finish with Chart Builder

In the output window, you should see a stacked bar chart of political orientation by gender while both males and females have 100% as their total percentages.

Stacked bar chart of political orientation by gender

Figure 33: Stacked bar chart of political orientation by gender

5. Producing a histogram

So far, we create graphs for categorical variables (nominal and ordinal). Can we visualise continuous variables? Yes, the histogram displays well a graphic representation of the distribution of a single continuous variable. It is a kind of bar chart that can be used with continuous variables. The difference is that in a histogram, the bars touch with each other. The widths of the bars represent the widths of the intervals, and the height of each bar represents the frequency of each interval. We will produce a histogram of age. To create it, go to Graphs > Legacy Dialogs > Histogram.

Graphs > Legacy Dialogs > Histogram.

Figure 34: Graphs > Legacy Dialogs > Histogram.

In the popped-up box, choose a variable you want to plot (in our case, it is age) and then move it to a pane labelled Variable by clicking the arrow next to Variable. Then, click OK.

Choose the variable you want to plot.

Figure 35: Choose the variable you want to plot.

You will see the histogram of age in the output window (see Figure 36).

histogram of age

Figure 36: histogram of age

6. Scatterplots

Scatterplots are an effective way to examine bivariate association in a graph format.

To create a scatterplot, go to Graphs > Legacy Dialogs > Scatter/Dot (see Figure 37). When you have only two variables, select the Simple Scatter (see Figure 38).

Graphs > Legacy Dialogs > Scatter/Dot

Figure 37: Graphs > Legacy Dialogs > Scatter/Dot

Chose Simple Scatter

Figure 38: Chose Simple Scatter

In a new popped-up window, 1) move your dependent variable (robbery) into Y Axis, 2) independent variable (unemploy) into X Axis, and 3) click OK.

Put your dependent variable in the y axis, and independent variable in the x axis

Figure 39: Put your dependent variable in the y axis, and independent variable in the x axis

Figure 40 is the scatterplot of robbery rate by unemployment rate. Do you see a pattern?

Scatterplot of robbery rate by unemployment rate.

Figure 40: Scatterplot of robbery rate by unemployment rate.

You can create scatterplots for several different variables so that we can determine whether there are any relationships among those multiple variables. To do so, you should select Matrix Scatter (see Figure 41) and put all the variables of interests into Matrix Variables (see Figure 42). It will return a output seen as Figure 43.

Select Matrix Scatter

Figure 41: Select Matrix Scatter

Put variables of interest into Matrix Variable

Figure 42: Put variables of interest into Matrix Variable

A Matrix Scatterplot

Figure 43: A Matrix Scatterplot

7. How to save SPSS graphs as a format of graphic files

Saving SPSS graphs as a format of graphic files (such as png or jpeg) is a convenient way to keep your graphic outcomes. And then you can import our graphic files into Word, PowerPoint, or iLearn. First, choose the chart you want to save in the output window. Then, right-click on the chart and select “Export”.

Right-click on the chart and select Export

Figure 44: Right-click on the chart and select Export

In the popped-up window, choose “Selected” in Object to Export, “None (Graphics only)” as Document Type, “PNG file (*.png)" as Graphics Type. Of course, you can choose any other graphic formats. Then, click Browse and you specify the folder where the graphic file will be saved.

Export Output dialogue box.

Figure 45: Export Output dialogue box.

In the popped-up window, click a small reverse triangle in the pane of Look in. Then, choose Desktop (it is your desktop (wallpaper)). Type the file name and click Save.

Choose Desktop. Type file name and click Save.

Figure 46: Choose Desktop. Type file name and click Save.

You will be back to the previous window. Then click OK at the bottom.

Then click OK at the bottom.

Figure 47: Then click OK at the bottom.

You will see the saved file on your desktop.

Last updated on 03 July, 2019 by Dr Nicholas Harrigan (nicholas.harrigan@mq.edu.au)