Strange black border of image from theme_base

ggplot(data = mntd,aes(x = div, y = NTI,)) +
geom_point() +
theme_base() +
xlab("Plant species richness")NTI-plant_richness

as you can see, I use theme_base() to plot, then I export it as an image. However, this ".png" file has three black borders (top, bottom and left), maybe you need to insert it into powerpoint for better observation.
I wonder how to remove these black borders.

See the FAQ: How to do a minimal reproducible example reprex for beginners for how to illustrate a problem in a way that is reproducible. You just need representative data, as shown below with a built-in dataset.

suppressPackageStartupMessages({
  library(ggplot2)
})
ggplot(data = mtcars,aes(x = cyl, y = mpg)) + # trailing comma is unnecessary
  geom_point() +
  xlab("Plant species richness") + # generally better to put theme last
  # theme_base() # there is no theme_base in the ggplot2 package
  theme_classic() # this is the theme that reproduces the problem

Try theme_minimal, which eliminates the border. Come back with a separate question if you also want "How to eliminate grid lines from ggplot?"

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.