I am plotting many points using ggplot with a constant transparency value for all points.
What I find is that the circular points have a more transparent fill than
Changing stroke to 0 seems to have hte desired result:
ggplot(data, aes(x,y)) +
geom_point(alpha=0.2, colour="dodgerblue", fill=mycol, stroke=0, size=5) +
theme(panel.background = element_rect(fill = 'black', colour = 'black'))
Given that you want disks with constant colour & opacity simplest thing to do that fixed it for me, also in the RStudio plot preview window is just to use option shape=16
:
data <- data.frame( x = sample(1:100,2000, replace=T),
y = sample(1:100,2000, replace=T) )
ggplot(d, aes(x,y)) +
geom_point(alpha=0.2, color="dodgerblue", size=5, shape=16) +
theme(panel.background = element_rect(fill = 'black', colour = 'black'))
Alternatively, shape=21
and a 100% semitransparent fill with
fill=adjustcolor("dodgerblue",alpha.f=0)
also works:
ggplot(data, aes(x,y)) +
geom_point(alpha=0.2, fill=adjustcolor("dodgerblue",alpha.f=0), size=5, shape=21) +
theme(panel.background = element_rect(fill = 'black', colour = 'black'))
Using stroke=0
as suggested in the currently accepted answer doesn't seem to resolve the problem entirely for me (ringing effect goes away a little bit but not entirely, this is on Windows at least) :
ggplot(data, aes(x,y)) +
geom_point(alpha=0.2, colour="dodgerblue", fill="dodgerblue", stroke=0, size=5) +
theme(panel.background = element_rect(fill = 'black', colour = 'black'))
Update: Tom Wenseleers solution (accepted) is better than the below.
After discussion with @42, the solution is that the PNG default had resolution low enough that at the border between a marker and the image background there was a blending artifact (might not be the right terminology).
Increasing the dpi solves the issue, and adding stroke=0
looks a bit better.
ggsave("plot.png",
ggplot(data, aes(x,y)) +
geom_point(alpha=0.2, color="dodgerblue", fill="dodgerblue", size=4, stroke=0) +
theme(panel.background = element_rect(fill = 'black', colour = 'black')),
dpi=1200)