
[英]Using ggplot2 (R) to color individual datapoints in boxplot by repeat
[英]Display single/individual observation in a sample population using R - boxplot ggplot2
我正在尝试使用boxplot ggplot2在400个人口中显示一个观察值。 我可以使用文本来显示它,但是我想使用与其他颜色不同的点来显示。 到目前为止,这是我设法编写的代码。 [![我还添加了一张有关结果外观的图片] [1]] [1]
HEXACO<-data10[, c("Record","Emotionality","Extraversion", "Agreeableness",
"Conscientiousness","Openness", "Honesty_Humility")]
data_long <- gather(HEXACO, hexaco, score, Openness, Conscientiousness, Agreeableness, Extraversion,
Emotionality, Honesty_Humility, factor_key=TRUE)
Oliver <-data_long[c(1, 11, 21, 31, 41, 51), c("hexaco", "score")]
HEXACO <- ggplot(data = data_long, aes(x= hexaco, y= score)) +
geom_boxplot(width = 0.6, fill = "lightgrey", alpha = 0.5) +
coord_flip() +
theme_USGS_box()+
scale_y_continuous(breaks=c(0,0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5))+
expand_limits(y = 1:5)+
geom_text(data = Oliver, label = "Oliver",size = 3)+
labs(title = "HEXACO Profile", x = "Honesty-Humilty", y = "Score")
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/9QYmp.png
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.