3

有一个ggpairs函数,如何将下刻面的范围限制为例如 x 和 y 的 0.5?

library(GGally)

xy <- data.frame(matrix(runif(4 * 1000), ncol = 4))

ggpairs(xy)

在此处输入图像描述

4

1 回答 1

6

您需要定义一个绘图(一个方面)的函数。你可以在这里疯狂ggplot。看到这个类似的问题

limitRange <- function(data, mapping, ...) { 
  ggplot(data = data, mapping = mapping, ...) + 
    geom_point(...) + 
    geom_smooth(method = "lm", se = FALSE) +
    scale_y_continuous(limits = c(0, 0.5)) +
    scale_x_continuous(limits = c(0, 0.5)) 
}

# This is how you specify which part of the image will be
# plotted using your function.
ggpairs(xy, lower = list(continuous = limitRange))

在此处输入图像描述

于 2018-11-13T09:23:17.903 回答