在我的真实研究世界中,在顶部(或顶部和底部)显示 x 轴,在右侧显示 y 轴是很常见的。但是,ggplot2 中的默认位置是底部的 x 和左侧的 y。
在Kohske Post Here之后,使用的命令是:
x <- seq(0, 10, 0.1)
y <- sin(x * pi)
qplot(x, y, geom = "line") +
scale_x_continuous(guide = guide_axis(position = "top")) +
scale_y_continuous(guide = guide_axis(position = "right"))
我在开发模式下尝试了上述命令:
install_packages("devtools")
library(devtools)
dev_mode()
install_github("ggplot2", "kohske", "feature/pguide")
library(ggplot2)
不幸的是,它不适用于最新的plyr
软件包。留言:
The following 'from' values not present in 'x': col, color, pch, cex, lty, lwd, srt, adj, bg, fg, min, max...
Error in plyr:::split_indices(seq_len(nrow(data)), scale_id, n)
然后我直接尝试了来自github的代码,消息是:
Error in continuous_scale(c("x", "xmin", "xmax", "xend", "xintercept"), :
formal argument "guide" matched by multiple actual arguments
我注意到哈德利说这个功能在他的待办事项清单上。但是,我目前找不到解决方案。有人可以帮忙吗?