0

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?

RL_Pug
  • 697
  • 7
  • 30

1 Answers1

2

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

Greg
  • 3,570
  • 5
  • 18
  • 31
  • That will work, but I want to use theme_clean() for its other features. Using theme_classic() gets rid of all the other formatting – RL_Pug Apr 08 '20 at 15:26
  • @FruityPebblePug I have edited the answer to work with `theme_clean` – Greg Apr 08 '20 at 15:50