R语言中ggplot绘图去除灰色背景并保留外围框线

 

001、R语言中ggplot绘图去除灰色背景并保留外围框线

library(ggplot2)

data <- data.frame(
  x = rnorm(10),
  y = rnorm(10)
)

ggplot(data, aes(x = x, y = y)) +
  geom_point() +
  theme(panel.background = element_blank(),        ## 去除灰色背景
  axis.line = element_line(colour = "black"),
  panel.border = element_rect(fill=NA,color="black", size = 1, linetype="solid"))      ## 增加外围框线

 

 

posted @ 2025-03-28 11:47  小鲨鱼2018  阅读(158)  评论(0)    收藏  举报