本文介绍了使用ggplot2标示geom_jitter()的特定点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 使用此代码时: t1 t2 t3 t5< )) t1 + t2 + t3 + t4 + t5 我得到与抖动点相结合的箱形图。然而,我也可以标出兴趣点,标签不是在特定点旁边,而是在箱形的垂直中间。 p> when using this code:t1 <- ggplot(mtcars, aes(x=as.factor(cyl),y=mpg))t2 <- geom_boxplot(outlier.shape=NA)t3 <- geom_jitter(width=0.3, size=1.5, aes(color = disp))t4 <- scale_colour_gradient(low="blue",high="red")t5 <- geom_text(aes(label=ifelse(mpg > 30,as.character(mpg),'')))t1 + t2 + t3 + t4 + t5I get a boxplot in combination with jitter points. I am also able to label the points of interest, however: the labeling is not next to the specific point, but rather in the vertical middle of the boxplot.Here is the figureAny idea how I can place the text next to the corresponding point?Thank you a lot guys!By the way: can you recommend me a course or a tutorial for ggplot2 beginners? 解决方案 Jitter it beforehand? library(ggplot2)set.seed(1)t1 <- ggplot(transform(mtcars, xjit=jitter(as.numeric(as.factor(cyl)))), aes(x=as.factor(cyl),y=mpg))t2 <- geom_boxplot(outlier.shape=NA)t3 <- geom_point(size=1.5, aes(x=xjit, color = disp))t4 <- scale_colour_gradient(low="blue",high="red")t5 <- geom_text(aes(x=xjit, label=ifelse(mpg > 30,as.character(mpg),'')), vjust = 1)t1 + t2 + t3 + t4 + t5 这篇关于使用ggplot2标示geom_jitter()的特定点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 21:07