我正在尝试在 ggplot 中生成哑铃图,同时还尝试记录转换 x 和 y 轴。系统抛出我无法理解的错误。寻求帮助。
这是示例代码:
#create the data
df <- data.frame(x = c(1, 2, 3, 100),
xend = c(2, 4, 6, 110),
y = c(1, 2, 3, 100))
#plot the untransformed dumbbell plot
library('ggalt')
ggplot(df, aes(x = x, xend = xend, y = y)) +
geom_dumbbell()
#Try the plot with coordinate transformation
ggplot(df, aes(x = x, xend = xend, y = y)) +
geom_dumbbell() +
coord_trans(x = 'log2', y = 'log2')
抛出错误:
[.data.frame
(df, , c("alpha", "color", "size", "linetype"))中的错误:
选择了未定义的列
如果我coord_trans
这样修改coord_trans(x = 'log2', xend = 'log2', y = 'log2)
,我会收到错误消息:
coord_trans(x = "log2", xend = "log2", y = "log2") 中的错误:
未使用的参数 (xend = "log2")
我想要的是相当于这个,geom_dumbbell()
而不是geom_point()
:
ggplot(df, aes(x = x, y = y)) +
geom_point() +
coord_trans(x = 'log2', y = 'log2')
关于如何让 geom_dumbbell() 与 coord_trans() 一起工作的任何想法?