geom_abline在ggplot2 r软件包中与geom_dotplot不符合GEOM_DOTPLOT

发布于 2025-02-13 13:22:51 字数 699 浏览 0 评论 0原文

这个问题与ggplot2 r软件包有关。为什么使用GEOM_DOTPLOT绘制的斜率数量会截断Geom_abline的截距?尝试以下示例:

testdata <- data.frame(predictor = c(0,1), dependent = c(0,2))

testplot <- ggplot(NULL) +
             geom_dotplot(data = testdata, aes(x = factor(predictor), y = dependent), binaxis = "y", stackdir = "center") +
             geom_abline(aes(intercept = 0, slope = 2))
testplot #The line is off

testplot <- ggplot(NULL) +
             geom_dotplot(data = testdata, aes(x = factor(predictor), y = dependent), binaxis = "y", stackdir = "center") +
             geom_abline(aes(intercept = 0 - 2, slope = 2))
testplot #The line aligns with the dots as expected

这是一个错误还是我在做愚蠢的事情?谢谢。

The question relates to ggplot2 R package. Why is the intercept of the geom_abline off by the amount of the slope when drawn with the geom_dotplot? Try the following examples:

testdata <- data.frame(predictor = c(0,1), dependent = c(0,2))

testplot <- ggplot(NULL) +
             geom_dotplot(data = testdata, aes(x = factor(predictor), y = dependent), binaxis = "y", stackdir = "center") +
             geom_abline(aes(intercept = 0, slope = 2))
testplot #The line is off

testplot <- ggplot(NULL) +
             geom_dotplot(data = testdata, aes(x = factor(predictor), y = dependent), binaxis = "y", stackdir = "center") +
             geom_abline(aes(intercept = 0 - 2, slope = 2))
testplot #The line aligns with the dots as expected

Is this a bug or me doing something silly? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文