2

I want to make a simple dot plot with solid circles using ggplot2 geom_point(). Interestingly, however, they are not 'perfect' circles when I copy-pasted the plot in a PDF software and scaled-up the image. It's done in Rstudio using export menu "copy to clipboard..." as metafile.

Of the pch values 16, 19, and 20 for solid circles, 16 makes circles with pixelated rough surface; 19 and 20 seem to make circles with off-centered circle fill.

Unfortunately, it looks like I am not allowed to upload images yet as a new user. But I had the same/similar result with the simple script below. currently, I'm using R version 3.6.1 (build 18362) and ggplot2_3.2.1

Am I the only one having this issue with ggplot2?

# made an example data frame
plot_test <- data.frame(x = c(1:5), y = c(2:6))

# plot the data frame using ggplot2
require(ggplot2)  
ggplot(plot_test, aes(x = x, y = y)) +
  geom_point(shape = 19, aes(size = x))  # 16, 19, or 20 for solid circle
GChoe
  • 23
  • 5
  • related: https://stackoverflow.com/questions/49240961/how-to-increase-resolution-of-ggplots-when-exporting-using-officer-r/49242178#49242178 – C8H10N4O2 Oct 09 '19 at 16:30

1 Answers1

4

Save the plot to svg to create "perfect" infinitely zoom-able circle.

library(svglite)
p <- ggplot(plot_test, aes(x = x, y = y)) +
  geom_point(shape = 19, aes(size = x))
ggsave(file="test.svg", plot=p)

enter image description here

yusuzech
  • 5,896
  • 1
  • 18
  • 33
  • Thanks yifyan. I found out that it happens when the plot is copy-pasted using "copy to clipboard..." as a Metafile in Rstudio plot export function. I have been using that 'trick' cause it's much more productive without going back and forth between folders, Powerpoint, and others. Now I realized the risk of taking the easy way. – GChoe Oct 09 '19 at 23:36