Having a ggpairs
function, how would one limit range of lower facets to e.g. 0.5 for x and y?
library(GGally)
xy <- data.frame(matrix(runif(4 * 1000), ncol = 4))
ggpairs(xy)
Having a ggpairs
function, how would one limit range of lower facets to e.g. 0.5 for x and y?
library(GGally)
xy <- data.frame(matrix(runif(4 * 1000), ncol = 4))
ggpairs(xy)
You need to define a function which plots (one facet). You can go wild with ggplot
in here. See this similar question.
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))