Control point border thickness in ggplot

后端 未结 3 1701
花落未央
花落未央 2020-11-29 04:21

When using ggplot, I can set shape to 21-25 to get shapes that have independent setting for the internal (fill) and border (col) color

3条回答
  •  醉梦人生
    2020-11-29 04:48

    Starting in version 2.0.0 of ggplot2, there is an argument to control point border thickness. From the NEWS.md file:

    geom_point() gains a stroke aesthetic which controls the border width of shapes 21-25 (#1133, @SeySayux). size and stroke are additive so a point with size = 5 and stroke = 5 will have a diameter of 10mm. (#1142)

    Thus, the correct solution to this is now:

    df <- data.frame(id=runif(12), x=1:12, y=runif(12))
    ggplot(df, aes(x=x, y=y)) + 
      geom_point(aes(fill=id, size=id), colour="black", shape=21, stroke = 2)
    

提交回复
热议问题