如何将 ggplot2 中的 jitter() 数量转换为position_jitter() 宽度?
我正在将使用基础图形的包更新为使用 ggplot2 图形的。在基本图形版本中,用户可以为 jj
提供一个值,然后该值将被缩放并传递给 jitter()
函数。抖动 x 值的代码如下所示:
degree.of.jitter <- (jj/200) * diff(x.values.range)
jitter(x.values, amount = degree.of.jitter)
我希望 ggplot2 版本能够实现与基本图形版本相同的视觉抖动效果。但是,我不确定如何重新缩放现有的 Degree.of.jitter,以便我可以将其直接传递给position_jitter() 并实现相同的视觉结果:
position_jitter(width = MysteriousScalingFunctionOfCompleteMysteryWhoseInnerWorkingsIHaveYetToSpecify(jj))
有人对 jj 的适当缩放比例有什么建议吗?
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, amount = 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在底层,
width
作为amount
参数传递给jitter
,因此您应该能够仅使用where
Degree.of .jitter
的定义方式与以前相同。Under the hood,
width
is passed as theamount
argument tojitter
, so you should be able to just usewhere
degree.of.jitter
is defined the same way as before.