我正在使用 ggplot2 生成下面的图。出于某种原因,它为我想要删除的子图引入了标题。当我删除geom_hline() 行时,它会以某种方式删除它们。但是,我需要那些水平线来表示边界。子图是从scale_y_cut()生成的。好像两者之间有串扰,我不明白。感谢您的帮助!
编码
library(ggsignif)
library(tidyverse)
library(ggpubr)
library(readxl)
library(rstatix)
library(stringr)
library(ggbreak)
CO2 <- CO2
ggplot(CO2, aes_string(x="Plant",y="uptake", fill="Plant"))+
geom_boxplot(outlier.alpha = 0.25, outlier.color = "red") +
geom_point(alpha = 0.25, size = 2 )+
facet_wrap(~Type)+
stat_compare_means(comparisons = list(c("Qn1","Qn2")), label.y = 105 )+
stat_compare_means(comparisons = list(c("Qc1","Qc2")), label.y = 110)+
stat_compare_means(comparisons = list(c("Mn1","Mn2")), label.y = 115)+
theme(axis.text.x = element_text(angle = 20))+
geom_hline(yintercept=100, linetype="dashed", color="red", size=1)+
geom_hline(yintercept=5, linetype="dashed", color="red", size=1)+
geom_hline(yintercept=130)+
geom_hline(yintercept=0)+
labs(y="uptake")+
scale_y_cut(breaks=c(7, 50, 95), which=c(1,2,3,4), scales=c(1,0.25,3,0.25))
如果可能的话,从图中删除那些拥挤的刻度线(0-6 和 50-100 之间)也会很好。谢谢您的帮助!