How to add a condition to the geom_point size?

后端 未结 2 399
鱼传尺愫
鱼传尺愫 2020-12-03 08:53

I am trying to add a condition to geom_point size and I\'ve pasted my example below. I would like geom_point size to be 2 when n_in_stat is 4 or more, and size = 5 when n_i

相关标签:
2条回答
  • 2020-12-03 09:25

    scale_size_manual sets the sizes for a discrete variable.

    geom_point(aes(size =n_in_stat>4)) + scale_size_manual(values=c(2,5))
    
    0 讨论(0)
  • 2020-12-03 09:30

    also you can just use a function:

    ff <- function(x){ifelse(x < 4, 5, 2)}
    

    and then change

    geom_point(aes(size = n_in_stat)) +
    

    with

    geom_point(aes(size = ff(n_in_stat))) +
    
    0 讨论(0)
提交回复
热议问题