function plotevents(A,B,C,E,X,Y,D,a,dr,T,dt,events)
% usage: plotevents(A,B,C,E,X,Y,D,a,dr,T,dt,events)
% description: plots the event data of an experimental run

% put the experiment in its own figure
figure
% now for massaging and displaying data...first the center
plot([X;X],[Y;Y],'kd');
axis([A,B,C,E]);
%axis equal;
grid,hold on;
xlabel('x');
ylabel('y');
% now we will layer these events with different colors
% for different times...this is crude, but illustrative
tstart = 0;
tend = T*dt;
timeranges = 4;
colors = 'kbgr';
timenodes = linspace(tstart,tend,timeranges+1);
% just for 'front' plotting
circle = exp(1i*(0:.01:2*pi));
cumevents = [];
for jj = 1:timeranges
  selectevents = TimeFilter(events,timenodes(jj),timenodes(jj+1));
  plot(selectevents(:,1),selectevents(:,2),strcat('o',colors(jj)),'LineWidth',2);
  cumevents = [cumevents;selectevents];
  % plot the 'front' of p. 336 of text, if a > 0.
  if (a > 0)
    radius = 2*sqrt(a*D)*timenodes(jj+1);
  else
    %otherwise get about 95% of the action inside the circle
    % we'll call that the 'front'
    tmprads = abs((cumevents(:,1)-X)+1i*(cumevents(:,2)-Y));
    tmprads = sort(tmprads);
    radius = tmprads(round(0.95*length(tmprads)));
  end
  plot(X+1i*Y + radius*circle,strcat('-',colors(jj)),'LineWidth',2)  
end
% plot the center
  plot(X,Y,strcat('o','r'));
title('Event scatter plot, color coded at four time intervals')
