The other thing I want to cover today is coordinate systems. The ggplot2 documentation shows seven coordinate functions. There are good reasons to use each, but I’m only going to demonstrate one. By default, we use the Cartesian coordinate system and ggplot2 sets the viewing space. This viewing space covers the fullness of your data set and generally is reasonable, though you can change the viewing area using the xlim and ylim parameters.
The special coordinate system I want to point out is coord_flip, which flips the X and Y axes. This allows us, for example, to turn a column chart into a bar chart. Taking our life expectancy by continent, data I can create a bar chart whereas before, we’ve been looking at column charts.
There are a lot of pictures and more step-by-step work. Most of these are still 3-4 lines of code, so again, pretty simple.