ggplot alpha levels appear different on fill and border of points (ringing artefact)

后端 未结 3 2053
野性不改
野性不改 2021-01-02 14:09

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

3条回答
  •  一个人的身影
    2021-01-02 14:46

    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)
    

提交回复
热议问题