File Exchange

image thumbnail

Flexible and Fast Spike Raster Plotting

version (138 KB) by Jeffrey Chiou
Plots spike rasters from spike times or binary trains. Faster than most implementations.


Updated 01 Apr 2014

View Version History

View License

This function quickly plots raster plots of large quantities of spike train data. Inputs can be spike times or binary spike train data organized by trial. It can also plot well-formatted single spike trains (example in zip file).
Speed is achieved by only plotting one object per figure (a line with segments separated by NaNs) and avoiding loops.
You can plot vertical lines, horizontal lines, and dots with formatting, on specific figures. You can also adjust the spike duration, relative spike start time, and vertical spike position. The x-axes for timing data are automatically set to show all spikes, but can alternatively be adjusted to your liking.
Please look at the .m file help for more extensive documentation. A test plotting file and sample figures are also attached.

Request features in comments, or to the email in my profile!

Cite As

Jeffrey Chiou (2021). Flexible and Fast Spike Raster Plotting (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (10)

Justin Fitzgerald


I take it back - just found 'XLimForCell' parameter =)


Works well except for one bug: crashes when there are no spikes to plot (this is annoying if plotting a bunch of data and occasionally there are some sets of trials without spikes) - would be nice to create blank plot in this case instead of crashing.


The function works but I keep receiving this error, am I the only one?

Error using plot
Error in color/linetype argument.

Error in plotSpikeRaster (line 446)
plot(xPoints, yPoints, 'color.k', lineFormat{:}); %plot(xPoints, yPoints, 'k', lineFormat{:});




Is cool but when the data is arranged in columns there is an error message, the program transposes them incorrectly. I had to turn my columns into rows. Other than that is great. Thanks


Thanks a lot for sharing this file :)


very nice

John Graef

Works great, very fast. Nice job!

MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!