Выровняйте точки данных с помощью графика.ggplot: geom_boxplot и geom_jitter
ДАННЫЕ:
data<-structure(list(score = c(0.058, 0.21, -0.111, -0.103, 0.051,
0.624, -0.023, 0.01, 0.033, -0.815, -0.505, -0.863, -0.736, -0.971,
-0.137, -0.654, -0.689, -0.126), clin = structure(c(1L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L), .Label =
c("Non-Sensitive",
"Sensitive "), class = "factor"), culture = structure(c(1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L
), .Label = c("Co-culture", "Mono-culture"), class = "factor"),
status = structure(c(2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L,
2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L), .Label = c("new", "old"
), class = "factor")), .Names = c("score", "clin", "culture",
"status"), class = "data.frame", row.names = c(NA, -18L))
КОДЫ:
p<-ggplot(data, aes(culture, as.numeric(score),fill=status))
p+geom_boxplot(outlier.shape = NA)+
theme_bw()+scale_fill_grey(start = 0.8, end = 1)+
labs(title="title", x="", y="score",fill="", colour="")+
geom_jitter(aes(colour = clin), alpha=0.9,
position=position_jitter(w=0.1,h=0.1))
Как вы можете видеть, точки данных, построенные с использованием geom_jitter не совпадают с boxplot. Я знаю, что мне нужно также предоставить элементы ees для geom_jitter, но я не уверен, как это сделать правильно.
http://stackoverflow.com/questions/19018568/possible-to-combine-position-jitter-with-position-dodge может помочь – user20650
Спасибо. Это очень помогает! – user3089803