ggplot2中单独增加某条边框的粗细

小鲨鱼2018 / 2023-07-23 / 原文

 

001、

library(ggplot2)
p<-ggplot(mtcars,aes(mpg,hp,colour=factor(cyl)))+geom_point()
p

p+theme(axis.line.x=element_line(linetype=1,color="black",size=0.3))+
  annotate(geom = 'segment', y = Inf, yend = -Inf, color = 'green',
           x = Inf, xend = Inf, size = 6)     ## Inf无穷大, -Inf无穷小