How to invert an axis in SPSS?
Is it possible to invert an axis in a SPSS graph, say -1,0,1 to 1.0, -1 without using code? I managed to change the coordination of the axes from x to y and vice versa, this was not what I wanted. I know that inverting is possible with code (or as they say in some forums), but I don't have the programming knowledge I need and would prefer an easier way if such a way exists.
source to share
It's ok if you don't have any programming knowledge. You really need some code to do this, but it's still very easy. If you can copy / paste, you can change the axis. Follow these steps:
- make your graph in the chart builder as usual,
- instead of clicking "OK" on the chart, click "Insert"
- your syntax window will show the diagram 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.
- just paste this
SCALE: linear(dim(1), reverse())
somewhere betweenBEGIN GPL
andEND GPL
(note: change dim(1)
to dim(2)
before inserting if you want to change 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.
- highlight and run this code and your graph will have a reverse axis.
source to share