FAQ/points - CBU statistics Wiki

Revision 10 as of 2011-09-15 10:05:14

Clear message
location: FAQ / points

How do I scatterplot observations which have the same set of co-ordinates?

Sometimes the same co-ordinates are shared by more than one observation. A scatterplot will only, however, show one point for each unique x,y combination regardless of the number of observations that share this combination.

One way of disentangling this is to add a proportionately small amount to the observed values of one of the variables, say, y. The below syntax uses the rv.uniform function in SPSS to add a small random amount to the y values when an x,y combination has previously occurred. The new values which are now all unique (ynew) can then be plotted against x.

sort cases by x.
sort cases by y.
COMPUTE copy=0. 
IF (x EQ LAG(x) AND y EQ LAG(y)) copy = 1. 

compute ynew = y.
if (copy eq 1) YNEW = Y + RV.UNIFORM(Y*0.01,Y*0.015). 

The above process is called jittering. In versions 13 to 16 of SPSS there is an option for "jittering" points in the menu. This is only available using the Interactive mode which is in versions 13 to 16 of SPSS. Select Graphs > Interactive > Scatterplot.... Double click on the plot and then on any data point. You should then see a 'jittering' tab. You can use this tab to jitter both x and y co-ordinates in the scatterplot so all points are then visible.

In later versions of SPSS (18 and 19) the jitter option can only be done using SPSS syntax as below for two variables, min (y-axis) and max (x-axis). You can then edit the graph in the usual way by double-clicking on it.

        /Y=VAR(min) TYPE=SCALE
        /X1=VAR(max) TYPE=SCALE