You do not need the theme() , as you can simply do this in coord_fixed() . For your example, you can do the following:
gg <- ggplot(xy,aes(x = x, y = y))+ geom_point() gg + coord_fixed(ratio=1,xlim=c(floor(min(xy$x,xy$y)), ceiling(max(xy$x,xy$y))), ylim=c(floor(min(xy$x,xy$y)), ceiling(max(xy$x,xy$y))))
using ceiling and floor in x- and y-lims, you have no problem that your axes are bounded over your outer points.
source share