1

How can I remove the plot border?

library(ggplot2)
library(ggthemes)
ggplot(cars, aes(speed, dist)) + geom_point() + theme_clean()

enter image description here

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggthemes_4.2.4 ggplot2_3.3.6 

loaded via a namespace (and not attached):
 [1] magrittr_2.0.1   tidyselect_1.1.1 munsell_0.5.0    colorspace_2.0-2 R6_2.5.1        
 [6] rlang_0.4.12     fansi_1.0.2      stringr_1.4.0    dplyr_1.0.7      tools_4.1.2     
[11] grid_4.1.2       gtable_0.3.0     utf8_1.2.2       withr_2.4.3      ellipsis_0.3.2  
[16] digest_0.6.29    tibble_3.1.6     lifecycle_1.0.1  crayon_1.4.2     farver_2.1.0    
[21] purrr_0.3.4      vctrs_0.3.8      glue_1.6.0       labeling_0.4.2   stringi_1.7.6   
[26] compiler_4.1.2   pillar_1.6.5     generics_0.1.1   scales_1.1.1     pkgconfig_2.0.3
mat
  • 2,412
  • 5
  • 31
  • 69

1 Answers1

2

You need plot.background = element_blank():

p <- ggplot(cars, aes(speed, dist)) + geom_point() + theme_clean()

Original plot:

p

enter image description here

With blank background:

p + theme(plot.background = element_blank())

enter image description here

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87