Skip to content
Snippets Groups Projects
Commit c1dce758 authored by Joanes Grandjean's avatar Joanes Grandjean
Browse files

make combined plot with ggarrange

parent 72aca635
No related branches found
No related tags found
No related merge requests found
......@@ -67,14 +67,28 @@ df <- read_csv('robotmod_data.csv') %>%
```{r}
df.SD_Rday1 <- df %>% filter(df$robot.day == 1, df$group == "SD")
p_1 <- ggplot(df.SD_Rday1, aes(x=trials, y=foraging.score, group=rat_ID))
p_1 + geom_line(color="gray", alpha=0.2)+
#summarize the percentage of foraging.score != 7 for each age in df.SD_Rday1
SD_Rday1_sum<-df.SD_Rday1 %>% group_by(trials, age) %>% summarize(percentage = sum(foraging.score != 7)/n())
fig1a <-ggbarplot(SD_Rday1_sum, x="trials", y="percentage",
color = "age", palette = c("#7fc97f", "#fdc086"),
size = 2, ylab = "foraging success [%]",
position = position_dodge(0.8))
p_1b <- ggplot(df.SD_Rday1, aes(x=trials, y=foraging.score, group=rat_ID))
fig1b<-p_1b + geom_line(color="gray", alpha=0.2)+
stat_summary(fun=mean, aes(group = age, color= age), geom="line", linewidth=2)+
stat_summary(fun.data = mean_se, aes(group=age, color = age), geom = "errorbar", alpha=1, width=0.05)+
scale_color_manual(values = c("#7fc97f", "#fdc086"))+
scale_y_continuous(breaks = seq(0, 7, by = 1))+
labs(x = "positions", y = "foraging score") + theme_classic() + facet_wrap(~age, ncol=2)
ggarrange(fig1a, fig1b, ncols=2,labels=c('A','B'), common.legend=TRUE, widths=c(1,2))
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment