15 Coordinate systems
Coordinate systems have two main jobs:
Combine the two position aesthetics to produce a 2d position on the plot. The position aesthetics are called
x
andy
, but they might be better called position 1 and 2 because their meaning depends on the coordinate system used. For example, with the polar coordinate system they become angle and radius (or radius and angle), and with maps they become latitude and longitude.In coordination with the faceter, coordinate systems draw axes and panel backgrounds. While the scales control the values that appear on the axes, and how they map from data to position, it is the coordinate system which actually draws them. This is because their appearance depends on the coordinate system: an angle axis looks quite different than an x axis.
There are two types of coordinate systems. Linear coordinate systems preserve the shape of geoms:
coord_cartesian()
: the default Cartesian coordinate system, where the 2d position of an element is given by the combination of the x and y positions.coord_flip()
: Cartesian coordinate system with x and y axes flipped.coord_fixed()
: Cartesian coordinate system with a fixed aspect ratio.
On the other hand, non-linear coordinate systems can change the shapes: a straight line may no longer be straight. The closest distance between two points may no longer be a straight line.
coord_map()
/coord_quickmap()
/coord_sf()
: Map projections.coord_polar()
: Polar coordinates.coord_trans()
: Apply arbitrary transformations to x and y positions, after the data has been processed by the stat.
Each coordinate system is described in more detail below.