相关疑难解决方法(0)

如何在ggplot2中更改x和y轴的位置

在我的真实研究世界中,在顶部(或顶部和底部)和右侧的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)

然后我直接尝试了github代码,消息是:

Error in continuous_scale(c("x", "xmin", "xmax", "xend", "xintercept"),  : …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

26
推荐指数
2
解决办法
2万
查看次数

标签 统计

ggplot2 ×1

r ×1