function h = plotevts(x, y, tick_height,color,txt) %PLOTEVTS Plot two vectors simulating a '|' line % h = = plotevts(x, y, ticktop,color,txt) % Returns a vector of handles to the lines created. % Arguements: % x = row vector of spike times % y = row vector of y position of events % tick_height = height bars (in Y dimensions) % color (optional specification of bar color) % txt = optional text to write at top of each bar % % RST 2006-04-05 if ~exist('color') color = 'b'; end if isempty(x) display('No events to plot'); return end if size(x,1) > 1 %if a column vector x = x'; end if size(y,1) > 1 y = y'; end ln_x = length(x); newx = zeros(2,ln_x); newy = newx; newx(1,:) = x; newx(2,:) = x; newy(1,:) = y; newy(2,:) = y+tick_height; h = plot(newx,newy, 'LineWidth', 0.01,'color', color); if exist('txt') hold on for i=1:ln_x txty = newy(2,i); if length(txt)==ln_x if ~ischar(txt(i)) txto = num2str(txt(i)); else txto = txt(i); end text( x(1,i),txty,txto,'Color',color,... 'HorizontalAlignment','center','VerticalAlignment','middle',... 'BackgroundColor','none','FontSize',8,'Interpreter','none',... 'Clipping','off') else text( x(1,i),txty,txt,'Color',color,... 'HorizontalAlignment','center','VerticalAlignment','middle',... 'BackgroundColor','none','FontSize',8,'Interpreter','none',... 'Clipping','off') end end end