R – point size in ggplot 2.0.0

ggplot2r

I'm having trouble recreating a plot since I updated to ggplot version 2.0.0: It seems I can't reduce the point size as much as before, which is a problem in a plot with very many points.
In the below examples, there is a reasonable difference in point size between plot1 and plot2, the point size in plot3 is at least a little bit smaller, but between plot3 and plot4 there's no difference in point size:

df <- data.frame(x=1:10, y=runif(10))
pl <- ggplot(df) +
    geom_point(aes(x,y), size=1)
ggsave("plot1.png", plot=pl, width=14, height=7, units="cm", dpi=1200 )

pl <- ggplot(df) +
    geom_point(aes(x,y), size=0.1)
ggsave("plot2.png", plot=pl, width=14, height=7, units="cm", dpi=1200 )

pl <- ggplot(df) +
geom_point(aes(x,y), size=0.01)
ggsave("plot3.png", plot=pl, width=14, height=7, units="cm", dpi=1200 )

pl <- ggplot(df) +
geom_point(aes(x,y), size=0.001)
ggsave("plot4.png", plot=pl, width=14, height=7, units="cm", dpi=1200 )

In the previous version of ggplot2 I had used a point size of 0.25 and it looked way smaller than it does now, which is why I tried to further reduce it using the new ggplot2 version. Do I miss a change in the code of the new version? Couldn't find anything in the documentation…

Best Answer

Ok, I've found the solution. As pointed out by @henrik and @silkita now the default shape has changed from 16 to 19 in the latest ggplot2 release. And as you can see in the documentation (for example here) the shape '19' is slightly larger than '16'. But this is not the reason why "points" are larger in version 2.0.0. Looking at the ggplot2 source of geom-point.R for the latest release we can see that:

default_aes = aes(
    shape = 19, colour = "black", size = 1.5, fill = NA,
    alpha = NA, stroke = 0.5
  )

While in the previous releases it was:

default_aes <- function(.) aes(shape=16, colour="black", size=2, fill = NA, alpha = NA)

Then, to have the small point as before we should put stroke to zero. To summarise, to obtain the smallest point you should write:

geom_point(size = 0.1) # ggplot2 before 2.0.0
geom_point(size = 0.1, stroke = 0, shape = 16) # ggplot2 2.0.0

By the way, when working with smallest points there is no difference between using different shapes (a pixel remains a pixel).

UPDATE: As pointed out on Twitter by Hadley Wickham this change was explained in the release notes

Related Topic