在我的真实研究世界中,在顶部(或顶部和底部)和右侧的y轴显示x轴是很常见的.但是,默认位置是底部的x和ggplot2中左边的y.
继Kohske张贴在这里,使用的命令是:
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"))
Run Code Online (Sandbox Code Playgroud)
我在开发模式下尝试了以上命令:
install_packages("devtools")
library(devtools)
dev_mode()
install_github("ggplot2", "kohske", "feature/pguide")
library(ggplot2)
Run Code Online (Sandbox Code Playgroud)
不幸的是,它与最新的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)
Run Code Online (Sandbox Code Playgroud)
Error in continuous_scale(c("x", "xmin", "xmax", "xend", "xintercept"), : …Run Code Online (Sandbox Code Playgroud)