Working with Graphics Production Language in IBM SPSS Statistics - dummies

Working with Graphics Production Language in IBM SPSS Statistics

By Keith McCormick, Jesus Salcedo, Aaron Poh

SPSS Command Syntax is the most well-known language in the Syntax window, but it isn’t the only one. There is a special language that can help you make amazing graphs: Graphics Production Language (GPL). Any programming language can be a little intimidating to learn at first, but GPL is a lot easier to learn than an initial glance might make you think.

If you paste from the Graph Build menu, you get something like this:

  /GRAPHDATASET NAME="graphdataset" VARIABLES=urpop educ
  SOURCE: s=userSource(id("graphdataset"))
  DATA: urpop=col(source(s), name("urpop"))
  DATA: educ=col(source(s), name("educ"))
  DATA: name=col(source(s), name("name"), unit.category())
  GUIDE: axis(dim(1), label("Percent Urban Population"))
  GUIDE: axis(dim(2), label("Education spending as % GNP"))
  ELEMENT: point(position(urpop*educ), label(name))

That seems like a lot to learn, but the trick is to start with the ELEMENT line. You can do some fun and valuable stuff just with that line, and then you can learn from there. Note the GGRAPH command. Just let SPSS Statistics do that for you. Just focus on the GPL right now.

Take a quick look at the “before” scatter plot in the following figure, made from the menus. The GPL above is unaltered.

The “before” scatterplot.

The “before” scatterplot.

It’s okay, but you can make two quick changes: Make the points red in color, and make them a little bigger.

ELEMENT: point(position(urpop*educ), label(name),
     color.interior(, size(size.medium))

There you have it. That’s all you have to change on the ELEMENT line to make those two changes as you can see in the following figure.

The “after” scatterplot.

The “after” scatterplot.

You may be wondering why you have to write size twice. It’s because this is a size constant. But you can get a little fancy, like this:

ELEMENT: point(position(urpop*educ), label(name), 
     color.interior(, size(pop) )

See what’s happened? Note that the pop variable is now in charge of the size.

Scatterplot with variable size.

Scatterplot with variable size.