Is it possible to jitter two ggplot geoms in the same way?

前端 未结 3 706
野的像风
野的像风 2020-12-15 20:42

Using position_jitter creates random jitter to prevent overplotting of data points.

In the below I have used the example of baseball statistics to illustrate my prob

3条回答
  •  孤城傲影
    2020-12-15 21:09

    This is a weakness in the current ggplot2 syntax - there's no way to work around it except to add the jitter yourself.

    Or you could do something like this:

    ggplot(baseball, aes(round(year,-1) + as.numeric(factor(lg)), sb, color = factor(lg))) +
      stat_summary(fun.data="mean_cl_normal") +
      stat_summary(fun.y=mean,geom="line") +
      coord_cartesian(ylim=c(0,40))
    

提交回复
热议问题