轴限制和“浮动”点-ggplot2

时间:2018-10-01 18:43:45

标签: r ggplot2

在用ggplot2创建的该箱图中,我试图将连续的y轴终止于30,并移除该轴在30之上的部分(请参见附图中的红色括号),同时将星号保持在x = 1.5,y = 35 ..这可能吗?这是我当前正在使用的代码[更新]:

g <- ggplot(methods_forGGP, aes(class, days)) + 
geom_boxplot(stat = "boxplot") +  
stat_summary(fun.y= mean, geom = "point", shape=4, size=4, colour="black") + 
theme_classic()+
theme(aspect.ratio= (2/(1+sqrt(5))), #landscape: golden ratio
    axis.title.y = element_text(colour = "black", size = 14, vjust= 2), 
    axis.title.x = element_text(colour = "black", size = 14, vjust=-0.5), 
    axis.text = element_text(colour = "black", size = 12))+ 
scale_x_discrete(labels=c("1"="A", "2"="B"))+ 
scale_y_continuous(breaks=seq(0,30,5))+ 
labs(x="X", y="Y")+

annotate(“ point”,x = 1.5,y = 35,shape =“ *”,colour =“ black”,size = 10) G Box Plot Image

1 个答案:

答案 0 :(得分:0)