I've been struggling with this for a long time. I'd like to create a raster plot in R to show the times of the action potentials (AP) of a neuron relative to a stimulus. Something like this: Each row represents the AP series in a given time window aligned to a stimulus repeated several times (sometimes at different frequencies)
I have a matrix containing the AP times relative to each stimulus (positive and negative time values).
I figured that stripchart
is a good solution as it plots one dimensional data. How can I plot each row of my matrix (or selected elements of the rows) to look like the attached image. I know that stripchart
function can also plot lists containing numeric vectors with different length, so first I selected the suitable elements from each row, created a list and ploted. I also tried as.list
function applied to the matrix so I didn't have to create a new list when I wanted to change the condition that selects the elements of the matrix. It seemed OK, but I have two problems with this. First, somehow I wasn't sure that it did the plotting correctly (row by row, selected elements) and also I'm not sure that this is the most effective way to do it. Second, since I had a lot of rows they didn't remain separate in the stripchart like they did on the first image. I've tried to adjust the parameters of the stripchart
function but nothing helped. My plot looks like this:enter image description here
In summary I'm looking for an effective way to plot matrix rows (selected elements) as one dimensional vectors keeping the rows separate on the image.
Thank you for your help!