I have a time series dataset of accelerometer data on which I've run some peak detections to identify different phases of the gait. I am using ggplot
to plot the left and right leg data as two facets in a facet_grid
, and now I want to overlay geom_rect
s to show the different phases of gait for each leg. I can add the rect layers ok, but I cannot figure out how to keep the left geom_rect
s to the left leg facet and the right geom_rect
s to the right facet. For example, during the gait cycle when your weight is on the left leg (stance phase for the left), the right leg is swinging forward (swing phase for the right), so the phase timings are different. You can see this by visually comparing the time points of the left vs. right troughs.
I've googled and SO'ed my way through the problem and I could not find an answer. The closest thing I've found is this but the author is using the same geom_rect
among the facets so it is not quite what I want. I attached a simplified Rscript and the data as csv
's. Can anybody give me some tips to make this plot?
facet_rects_test.zip (.csv and R Script)
thanks!