【发布时间】:2017-12-13 22:27:00
【问题描述】:
我想在情节 1) 中添加每个条件的主题和重复次数的总平均值;和 2) 在图例上添加此项。
使用此代码(编辑:我制作了一个类似的 df 来解决我的问题):
Npoint = 12; Ncond = 7; Nrep = 3; Nsubj = 2;
data_a <- c(sample(c(-2,22), Nrep*Npoint, replace = TRUE), sample(c(38,60), Nrep*Npoint, replace = TRUE),
sample(c(46,62), Nrep*Npoint, replace = TRUE), sample(c(26,44), Nrep*Npoint, replace = TRUE),
sample(c(42,58), Nrep*Npoint, replace = TRUE), sample(c(46,58), Nrep*Npoint, replace = TRUE),
sample(c(38,56), Nrep*Npoint, replace = TRUE), sample(c(-2,22), Nrep*Npoint, replace = TRUE),
sample(c(38,60), Nrep*Npoint, replace = TRUE), sample(c(46,62), Nrep*Npoint, replace = TRUE),
sample(c(26,44), Nrep*Npoint, replace = TRUE), sample(c(42,58), Nrep*Npoint, replace = TRUE),
sample(c(46,58), Nrep*Npoint, replace = TRUE), sample(c(38,56), Nrep*Npoint, replace = TRUE))
subj_t <- rep(c("s01", "s02"), each=Npoint*Ncond*Nrep);
cond_t <- rep(c("Quiet","1","1.41","2","2.82","4","TEN"), each=Nrep*Npoint, times=Nsubj);
rep_t <- rep(c("a","b","c"), each=Npoint, times=Ncond*Nsubj);
RAC_QST_a <- data.frame(data=data_a, subj=factor(subj_t), cond=factor(cond_t), rep=factor(rep_t))
library(ggplot2); library(forcats);
ggplot(RAC_QST_a, aes(x=fct_inorder(cond), y=data, group=interaction(subj,rep), color=subj, shape=rep, na.rm=TRUE)) +
theme_bw() +
stat_summary(fun.y = "mean", geom = "point", size = 2.5) +
stat_summary(fun.data = mean_sdl, geom = "errorbar", size = .25, linetype = "solid") +
stat_summary(fun.y = "mean", geom = "line", size = .25, linetype = "dashed") +
stat_summary(fun.y = "mean", aes(group = cond), geom = "point", size = 3, shape=1, colour="black") +
scale_y_continuous(breaks = c(10,20,30,40,50,60), label = c(10,20,30,40,50,60)) +
labs(title = "behavioural RAC", x = "Notch Central Freq [KHz]", y = "Threshold [dB SPL]")
我有这张图片,请看这里:http://imgur.com/LU8QJgm
那么,请问我怎样才能在圆圈之间添加黑线并在腿上添加条目?
我无法根据我的情况调整这个答案Add an entry to the legend for a manually added line……
提前谢谢你
【问题讨论】: