简体   繁体   中英

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

在此处输入图像描述

How can I remove the black square border?

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"
  ))

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM