@baptiste, facet_wrap = "free" ggplot2 geom_blank
. , ggplots , , .
library(ggplot2)
set.seed(11)
d = rbind(
data.frame(what = "a", v1 = rnorm(20) + 0.2, v2 = rnorm(20)),
data.frame(what = "b", v1 = rnorm(20, 100, 10) + 20, v2 = rnorm(20, 100,10)))
drange = do.call(rbind, by(d, d$what, function(x) extendrange(c(x$v1, x$v2))))
dummy = data.frame(what = rownames(drange), v1 = drange[,1], v2 = drange[,2] )
ggplot(d, aes(x = v1, y = v2 )) +
geom_point() +
geom_abline(slope = 1) +
theme(aspect.ratio = 1) +
coord_fixed(ratio = 1, expand = FALSE) +
stat_ellipse() +
geom_blank(data = dummy) +
facet_wrap(~what, scales = "free")
, , .
lattice::xyplot(v2~v1|what, data = d, aspect = 1, pch = 16,
scales = list(relation = "free"),
panel = function(x,y, ...){
lattice::panel.xyplot(x, y, ...)
lattice::panel.abline(a = 0, b = 1)
},
prepanel = function(x, y, ...){
lim = c(min(x, y), max(x, y))
list(xlim = lim, ylim = lim)
})