开发者

How can I convert from jitter() amounts to position_jitter() widths in ggplot2?

I'm updating a package that uses base graphics to one that uses ggplot2 graphics. In the base graphics version, users could supply a value for jj, which would then get scaled and passed to a jitter() function. The code to jitter x values looked like this:

degree.of.jitter <- (jj/200) * diff(x.values.range)
jitter(x.values, amoun开发者_Go百科t = degree.of.jitter)

I'd like the ggplot2 version to achieve the same visual jittering effect as the base graphics version. But, I'm not sure how to re-scale my existing degree.of.jitter so I can pass it directly to position_jitter() and achieve the same visual results:

position_jitter(width = MysteriousScalingFunctionOfCompleteMysteryWhoseInnerWorkingsIHaveYetToSpecify(jj))

Does anyone have any suggestions for what the appropriate scaling of jj would need to be?


Under the hood, width is passed as the amount argument to jitter, so you should be able to just use

position_jitter(width = degree.of.jitter)

where degree.of.jitter is defined the same way as before.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜