Lazaros Mitskopoulos
Lazaros Mitskopoulos

Reputation: 131

How to invert an axis in SPSS?

Is it possible to invert an axis in an SPSS graph, say from -1,0,1 to 1,0,-1 without using code?I have only been able to change the axes' coordination from x to y and reverse which was not what I wanted. I know inverting is possible with a code (or so they say in some forums) but I have zero knowledge on programming and I would prefer an easier way if such a way exists.

Upvotes: 3

Views: 5051

Answers (2)

Mel
Mel

Reputation: 1

In the newest version of SPSS the only code you have to enter in the syntax is reverse ()) and you paste this behing the code SCALE: linear(dim(2), so it will ook like this: SCALE: linear(dim(2), reverse ())

Upvotes: 0

DocBuckets
DocBuckets

Reputation: 261

It's ok if you don't have programming knowledge. You do indeed need code to do this, but it is still very easy. If you can copy/paste, you can reverse an axis. Follow these steps:

  1. make your graph in chart builder like you normally would
  2. instead of pressing "OK" to graph, press "Paste"
  3. your syntax window will show some chart code.

Here's an example:

* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=var1 var2 MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: var1=col(source(s), name("var1"))
  DATA: var2=col(source(s), name("var2"))
  GUIDE: axis(dim(1), label("X"))
  GUIDE: axis(dim(2), label("Y"))
  ELEMENT: point(position(var1*var2))
END GPL.
  1. simply paste this SCALE: linear(dim(1), reverse()) somewhere between BEGIN GPL and END GPL

(note: change dim(1) to dim(2) before you paste if you want to reverse the y axis)

* Chart Builder.
GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=var1 var2 MISSING=LISTWISE REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: var1=col(source(s), name("var1"))
  DATA: var2=col(source(s), name("var2"))
  SCALE: linear(dim(1), reverse())
  GUIDE: axis(dim(1), label("var1"))
  GUIDE: axis(dim(2), label("var2"))
  ELEMENT: point(position(var1*var2))
END GPL.
  1. highlight and run that code and your graph will have a reversed axis

Upvotes: 2

Related Questions