Hi, I have a data set like this one below:
DataFrame <- data.frame(x=runif(25),y=runif(25),
z=sample(letters[1:4],25,rep=TRUE))
and using the Lattice package, I can make a scatter plot with equal axes (with a 1:1 line going through the centre) with the following lines:
xyplot(y ~ x | z, data=DataFrame,
scales=list(relation="free"),
prepanel=function(x,y,...) {
rg <- range(na.omit(c(x,y)))
list(xlim=rg,ylim=rg)
},panel=function(x,y,...) {
panel.abline(0,1)
panel.xyplot(x,y,...)
})
In ggplot2, I have gotten this far:
ggplot(data=DataFrame) + geom_point(aes(x=x,y=y)) +
facet_grid(~z,scales="free") + coord_equal(ratio=1) +
geom_abline(intercept=0,slope=1)
But I'm not sure that coord_equal() is the function I'm looking for. What might be the equivalent function call in ggplot2?