首页 > 解决方案 > Geom_segment 没有读取缺失的美学:x、y、xend 和yend Piper Plot

问题描述

我试图在这里重现 Piper 图:https ://github.com/markolipka/ggplot_Piper但是我不断收到错误消息: 错误:geom_segment 需要以下缺失的美学:x、y、xend 和yend,
尽管 x、y、xend并在代码中指定了yend: https ://pastebin.pl/view/3a5dfd01

有没有人使用过这个 Piperplot 代码?谁能指出我需要删除或添加的正确方向?

标签: rggplot2plotlygeom-segment

解决方案


没有可重复的例子很难说。

尝试以下操作:

b <- ggplot(mtcars, aes(wt, mpg)) +
  geom_point()

df <- data.frame(x1 = 2.62, x2 = 3.57, y1 = 21.0, y2 = 15.0)

b +
 geom_curve(aes(x = x1, y = y1, xend = x2, yend = y2, colour = "curve"), data = df) +
 geom_segment(aes(x = x1, y = y1, xend = x2, yend = y2, colour = "segment"), data = df)

如果它有效,那么我敢打赌你的数据框有问题。可能是您的变量不存在或格式错误。它不起作用,那么您可能必须再次安装 ggplot。


推荐阅读