RL_Pug
RL_Pug

Reputation: 887

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

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?

Upvotes: 3

Views: 2506

Answers (1)

Greg
Greg

Reputation: 3670

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

Upvotes: 4

Related Questions