Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
# (PART) Scales {-}
# Introduction {#scales .unnumbered}
```{r setup, include = FALSE}
columns(1, 2 / 3)
Scales in ggplot2 control the mapping from data to aesthetics. They take your data and turn it into something that you can see, like size, colour, position or shape. They also provide the tools that let you interpret the plot: the axes and legends. You can generate plots with ggplot2 without knowing how scales work, but understanding scales and learning how to manipulate them will give you much more control.
In ggplot2, guides are produced automatically based on the layers in your plot. You don't directly control the legends and axes; instead you set up the data so that there's a clear mapping between data and aesthetics, and a guide is generated for you. This is very different to base R graphics, where you have total control over the legend, and can be frustrating when you first start using ggplot2. However, once you get the hang of it, you'll find that it saves you time, and there is little you cannot do.
The scales toolbox divide scales into three main groups, covered in separate chapters:
* Position scales and axes are described in Chapter \@ref(scale-position).
* Colour scales and legends are described in Chapter \@ref(scale-colour).
* Scales for other aesthetics are described in Chapter \@ref(scale-other).
The theory of scales is covered in Chapter \@ref(scales-guides), which expands on these chapters as well as other sections in the book that refer to scales (e.g., Section \@ref(titles) is extended by Section \@ref(scale-names)).