I'm using a ribbon geom to create graphics across time such as in this example:
https://sites.google.com/site/wolfydummysite/home/phangle1.jpeg
which has been created by this code:
ggplot( data=S05RUEtablanrmmJ5,aes(x=Time,y=Phase_Angle)) +
geom_line(aes(group=Jorang:k,color=Jorang),size=I(1)) +
#geom_point(aes(group=Jorang,color=Jorang,),size=I(1)) +
facet_wrap(~variable) +
stat_summary(data=RUEtablanrmmJH,fun.data=mean_sd, geom="ribbon", alpha=0.25,aes(group=Jorang:Cond,y=Phase_Angle)) +
stat_summary(data=RUEtablanrmmJH,fun.data=mean_sd, geom="line",aes(group=Jorang:Cond,color=Jorang:Cond,y=Phase_Angle),size=I(1))+
scale_colour_manual(values = colorin3)
where
"mean_sd" <- function(x, mult = 1) {
x <- na.omit(x)
sdev <- mult * sqrt(var(x))
mean <- mean(x)
a=data.frame(y = mean, ymin = mean - sdev, ymax = mean + sdev)
# a=data.frame(y = mean, ymin = mean - 20, ymax = mean + 20)
a
}
(essentially following
http://stackoverflow.com/questions/4205428/show-standard-devation-using-geom-smooth-and-ggplot)
With these data:
https://sites.google.com/site/wolfydummysite/home/RUEtablanrmmJH.rdahttps://sites.google.com/site/wolfydummysite/home/S05RUEtablanrmmJ5.rda
Now I would like to make a similar plot for the relationship between two variables ordered by time, but
cannot get the ribbon on it.
The plot with all observations an without ribbon would be:
https://sites.google.com/site/wolfydummysite/home/angvel_orang1.jpegwhich has been created by
ggplot( data=RUEtablanrmmJ5,aes(x=Orientation_Angle,y=Angular_Velocity)) +
geom_path(aes(group=Jorang:k,color=Jorang:Cond),size=I(1)) +
facet_wrap(~variable) +
scale_colour_manual(values = colorin3)
As the plot is too complicated, I'd like to represent the mean and the ribbon of sd for "SFE:H" and "EFE:H" individuals
(6 individuals for each) and not the path for each individual. I've tried the following:
ggplot( data=S05RUEtablanrmmJ5,aes(x=Orientation_Angle,y=Angular_Velocity)) +
geom_path(aes(group=Jorang:k,color=Jorang),size=I(1)) +
facet_wrap(~variable) +
stat_summary(data=RUEtablanrmmJH,fun.data=mean_sd, geom="ribbon", alpha=0.25,aes(group=Jorang:Cond)) +
scale_colour_manual(values = colorin3)
https://sites.google.com/site/wolfydummysite/home/angvel_orang2.jpeg
and several variations, with no good results.
Any help appreciated!
Thanks
Joan
--
Joan Lobo Prat
BSc. Industrial Design Engineering
Escola Superior de Disseny ELISAVA (SPAIN)
MSc. Biomedical Engineering - Student
Universitat Politècnica de Catalunya - Universitat de Barcelona (SPAIN)
www.sites.google.com/site/joanloboprat/
+34 627 625 264 (SP)
+31 (0) 624 951 375 (NL)