How to remove black border around plots/graphics in ggplot2? R

1.8k Views Asked by At

I'm creating some plots but every one I make has a black square border? How can I make this border white or remove it completelty?

Here is my code

library(ggplot2)
library(ggthemes)

ggplot(mtcars, aes(x = mpg)) + 
  geom_point(aes(y = hp)) + 
  theme_clean(base_size=18)


Here is my output plot that pasted into paint and used red arrows to point at the black border around my plot

enter image description here

How can I remove the black square border?

1

There are 1 best solutions below

2
Greg On BEST ANSWER

Edit the plot.background element of theme, changing color to white

library(ggplot2)
library(ggthemes)
data(mtcars)
ggplot(mtcars, aes(x = mpg)) +
  geom_point(aes(y = hp)) +
  theme_clean() +
  theme(plot.background = element_rect(
    color = "white"
  ))

enter image description here