Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invert an axis in SPSS?

Tags:

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.

like image 223
Lazaros Mitskopoulos Avatar asked Dec 08 '25 21:12

Lazaros Mitskopoulos


1 Answers

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
like image 83
DocBuckets Avatar answered Dec 12 '25 07:12

DocBuckets



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!