Can't remove white edge of ggplot2-plot


I would like to make a plot with ggplot2 and import it into illustrator. Though I set the theme as such that there should be a transparent background, all of my plots have a white edge around them which I can't get rid of. For example:


p = ggplot()+
  geom_function(fun = dnorm)+
      rect = element_rect(fill = "transparent"),
      panel.background = element_blank(), #transparent panel bg
      panel.grid.major = element_blank(),
      panel.grid.minor = element_blank()

  plot = p,
  filename = "example.eps",
  bg = "transparent",
  width = 7,
  height = 7,
  dpi = 500

when I export the plot and import it into Adobe Illustrator over a coloured background I get this:

The red circle indicates the white edge I'd like to get rid of. Any ideas?
Thanks in advance!


maybe this does what you want it to do:


  geom_function(fun = dnorm) +
  theme_void() +
  labs(y = 'y') +
    axis.title = element_text(),
    axis.text = element_text(),
    rect = element_rect(fill = NA)

Created on 2022-08-18 by the reprex package (v2.0.1)

Since I do not have Adobe Illustrator, I can't check for the "white edge".

Best regards

1 Like

Ill give it a try, thanks:)

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.