Chapter 1: scatterplots

In Fig. 1.6 the x-y positions of a hypothetical fingertip were displayed. To create this plot our first step will be to define an N x 2 set of x-y positions. Lacking real experimental data, we will generate simulated data by typing (at the command line):

XYdat=mvnrand([0 0],[1 0 ; 0 1],50);

This command creates a 50x2 matrix of points where the mean of the first column of 50 numbers has an average near 5 and the second column of 50 numbers has an average near 1. We will have more to say about the Matlab random number generators in Chapter 4, but you should examine the help file associated with this command now (by typing help mvnrnd at the command line).

To create a scatterplot with these data, we simply plot the N x 2 matrix of numbers (here representing x-y positions), where the x-component of the data is contained in the first column of the matrix and the y-component of the eye position data is contained in the second column of the matrix, making use of the plot.m function. The plot command takes at least two arguments, the first is the vector of x-data and the second is the vector of y-data. There are also optional arguments for the type of plot symbol and the size and desired colors of the edges and centers of plot symbols. So, for example, to plot start position at the origin, we type:

figure; hold on; plot(0,0,'o','MarkerSize',12,'MarkerFaceColor',[0 0 0],'MarkerEdgeColor',[0 0 0])

where the third argument (‘o’) is the marker type (a circle), and the remaining arguments are pairs of argument identifiers in text and corresponding values. Thus, for example, the input pair that allows us to specify the size of the plotted circle is ‘MarkerSize’ followed by the size of the marker (12). To plot the location of the icon, we type:

Finally, we plot the scatter of saccade endpoint locations:

plot(XYdat(:,1),XYdat(:,2),'.','Color',[.4 .4 .4])

Here, the marker is a darker grey. Note that wen the plot symbol is the dot (‘.’), we do not specify edge and face colors separately, since it is always a single solid color without a separate edge and face. Similarly, we do not specify a size for the dot symbol, which has a standard unmodifiable size.