The coordinate system of a plot, together with the x and y position scale, determines the location of geoms.
Assume the following data frame:
d=data.frame(height=c(1,2,2,3,4), weight=c(1,3,4,4,2))
And assume the following plot:
p = ggplot() + geom_line(data=d, mapping=aes(x=height, y=weight)) + geom_point(data=d, mapping=aes(x=height, y=weight), size=8, fill="white", shape=21) + geom_text(data=d,mapping=aes(x=height, y=weight, label=seq(1,nrow(d))))
p + coord_cartesian()
p + coord_flip()
p + coord_trans(xtrans="log10", ytrans="log10")
p + coord_equal()
p + coord_polar(theta="x")
p + coord_polar(theta="y")
Load the "maps" package and create a data frame containing the latitudes and longitudes of the map of Italy.
require(maps) d = data.frame(map(database="italy", plot=F)[c("x", "y")])
Create a plot using coord_map
with its default (mercator) projection:
ggplot() + coord_map() + geom_polygon(data=d, mapping=aes(x=x, y=y), fill=hsv(0, 1, 0.7), color=hsv(0, 1, 0.5), size=0.2)