我想在每个facet图中添加一条平均线(特定于每个物种和变量),但只设法在没有线的情况下绘制facet。如果您想尝试,我还附上了一份数据样本。
data_tidy = data %>%
group_by(species) %>%
gather(variable, value, duration, voiced, ampl_median, ampl_sd, amplVoiced_mean,
amplVoiced_median) %>%
dplyr::select(species,variable,value)
ggplot(data_tidy,aes(x=value,y=..scaled..,fill=variable))+
geom_density()+
facet_grid(species~variable,scales="free")+
geom_vline(data=data_tidy, aes(xintercept=mean(value)), colour="grey50")
Screenshot of attempt (without average line)
示例数据位于:https://drive.google.com/open?id=1u_6u6bXMfdut91bhAFIACHIt5CCGaMl2
提前致谢。