SPSS Chart Templates Tutorial

SPSS chart templates are tiny text files
that contain styling for charts.

Practice Data File

This tutorial walks you through creating and using chart templates. We’ll use bank.sav -partly shown below- throughout. We encourage you to follow along with the examples.

SPSS Bank Sav Data View

What are SPSS Chart Templates?

In SPSS, chart templates are tiny XML files containing styling for charts. You can use chart templates for things like

  • setting colors, fonts and borders for one or many charts;
  • transposing one or many charts;
  • hiding elements -titles or axis labels- from one or many charts;
  • setting sizes for one or many charts.

The file extension for chart templates is .sgt -short for SPSS graph template. You’ll find some examples in the Looks folder as shown below.

SPSS Chart and Table Templates in Looks Subfolder

However, these templates are pretty worthless. If you really want to benefit from chart templates, you’d better create your own. This is much easier than you might think. Let’s go.

Creating a Chart Template

Right. So I’d like to visualize the frequency distribution for marital status. One option is creating a bar chart from Graphs SPSS Menu Arrow Legacy Dialogs SPSS Menu Arrow Bar as shown in our SPSS Bar Charts Tutorial.
Adding a title and a subtitle resulted in the syntax below.

*Basic bar chart with title and subtitle for marital status.

GRAPH
/BAR(SIMPLE)=COUNT BY marit
/title ‘Frequency Distribution Marital Status’
/subtitle ‘All Respondents | N = 458’.

Result

SPSS Bar Chart Legacy Styling

So there’s my bar chart. And it looks terrible. Double clicking it, however, opens a Chart Editor window in which I’ll style my chart. I’ll transpose it as well.

SPSS Style Chart In Chart Editor

After spending a couple of minutes on styling my chart, the best I could come up with is shown below. You’ll probably come up with something better if you go through some trial and error.

SPSS Bar Chart Styled Manually

The chart looks much nicer because I changed its styling rules. Some of those rules are

  • transpose the chart;
  • use purple for the bars;
  • use white as a background color;
  • show the title left and the subtitle right at similar vertical positions.

The trick is that I can nowsave all styling rules without saving the actual chart.We’ll start off by making sure we’re in the Chart Editor window -which is not the same as the Output Viewer. Here we’ll navigate to File SPSS Menu Arrow Save Chart Template as shown below.

SPSS Save Chart Template From Chart Editor Menu

Next, we’ll select All settings.

SPSS Save Chart Template All Settings Dialog

Finally, choose a folder and a file name. Clicking the Save button now creates transposed-bar-chart-frequencies-1.sgt. Feel free to download and try it.

SPSS Save Chart Template Path Dialog

Applying Chart Templates

We can now activate this chart template by running something likeset ctemplate
‘transposed-bar-chart-frequencies-1.sgt’.
You may need to use a full path here if the template file is not in your default directory as set with CD. From now on, all charts we’ll run will have the styling we created for our bar chart. If you don’t want that anymore, you can deactivate this template by runningset ctemplate none.From now on, all charts will have SPSS’ default styling again.

There’s many other ways to apply chart templates to one or many charts.

  • You can apply a chart template to an existing chart manually by using File SPSS Menu Arrow Apply Chart Templatein the Chart Editor.
  • You can apply a chart template to a selection of existing charts with Python scripting.
  • OUTPUT MODIFY can apply a chart template to a selection of existing charts. However, this doesn’t work properly because it sets the wrong sizes.
  • You can activate a template under Edit SPSS Menu Arrow Options SPSS Menu Arrow Charts. We don’t recommend this as it’s basically just the wrong way to run SET CTEMPLATE as proposed previously.
  • A surprising number of commands have a /TEMPLATE subcommand. This applies a template to only the charts created by this command. This doesn’t work properly because the template doesn’t completely overrule the previous template in some cases.

In short, we recommend youalways use SET CTEMPLATE… for applying chart templatesto future charts. This seems to be the only method that always works properly.

Where Do I Get Chart Templates?

There’s several options for obtaining SPSS chart templates:

  • Create and develop your own set of chart templates. Basic templates won’t pose too much of a challenge. For really nice templates, though, you’ll need to dive into the actual XML as we’ll show in a minute.
  • To some extent, you can extract a chart template from any existing chart in an SPSS output (.spv) file.
  • Ask a specialist to develop some templates for you. We also offer this service but we do charge for it.
  • Use the chart templates that are shipped with SPSS. You’ll find them in the Looks folder but -honestly- you may find them pretty worthless.

Developing SPSS Chart Templates

In contrast to SPSS table templates, you’ll probably want to develop a separate chart template for each type of chart you run. Thus far, we created a chart template from the Chart Editor menu. Although this is a good first step, this has its limitations. Those who’d like to develop much better templates should try and adjust their XML in a text editor such as Notepad++.

SPSS Chart Template Xml NotepadChart template (.sgt) files contain XML which can you can edit.

Manually editing the XML is an optional extra step in developing chart templates. If you’re not afraid of code, it’ll help you develop much better templates than purely relying on the menu. You can also change some styles faster. For example, use the Ctrl + H shortkey to search and replace all font sizes or colors.

SPSS Bar Chart With Chart Template

Summarizing some main points in this tutorial, the flowchart below proposes a development cycle for SPSS chart templates.

SPSS Chart Template Development Cycle

Final Notes

Developing chart templates may take some time and trial and error. However, if you create SPSS charts on a regular basis, it’ll be well worth the effort. In any case, I hope this introduction will get you started.