Search code examples
rggplot2inkscape

ggplot PDF import to Inkscape adds extra hollow circles to geom_point dots when using alpha


How to prevent Inkscape from adding extra circles to geom_point() dots when using alpha (transparency) when importing a ggplot figure in .pdf format?

Make figure:

ggplot(mtcars,aes(wt,mpg)) + geom_point(alpha=0.5)

Save as PDF:

ggsave('inkscape_bug.pdf')

I get these perfectly smooth semi-transparent circles (zoomed screenshot of resulting .pdf file):

enter image description here

But when I export to Inkscape, in addition to the semi-transparent full circles also appear smaller and darker hollow circles on top:

enter image description here

Tried: This is probably a duplicate (I can't believe no one else has had this problem before) but I can't find the right keywords to find the correct threads. The only thing I can find is to add useDingbats=FALSE, but even that doesn't fix this issue.

I also tried changing the options when importing to Inkscape (Popper/Cairo import, Internal import, [unchecked] Replace PDF fonts by closest-named installed fonts and Embed images), to no avail. Interestingly, I get the same result directly (without exporting to Inkscape or any other software) if I save as .svg instead of .pdf. Weird isn't it?

Question: 1) Why does it do that? 2) How to prevent it?


Solution

  • Use shape = 16 in your geom_point. The default ggplot point shape is 19, which has a border.