我有我认为是y^2~x的数据。 所以,我想把y画成x的函数,并对y进行一些变换。
N <- 100 ggplot(data_frame(x = runif(N), y = 20 * sqrt(x) + rnorm(N)), aes(x, y)) + geom_point()
+ scale_y_square 是吗?是吗?
+ scale_y_square
你需要做一个新的转变 scales::trans_new 和它一起使用 coord_trans 以下内容:
scales::trans_new
coord_trans
N <- 100 ggplot(data_frame(x = runif(N), y = 20 * sqrt(x) + rnorm(N)), aes(x, y)) + geom_point() + coord_trans(y = scales::trans_new("square", function(x) x^2, "sqrt"))