Scales control the mapping from data to aesthetics. They take your data and turn it into something that you can perceive visually: e.g., size, colour, position or shape. Scales also provide the tools you use to read the plot: the axes and legends (collectively known as guides). Formally, each scale is a function from a region in data space (the domain of the scale) to a region in aesthetic space (the range of the range). The domain of each scale corresponds to the range of the variable supplied to the scale, and can be continuous or discrete, ordered or unordered. The range consists of the concrete aesthetics that you can perceive and that R can understand: position, colour, shape, size and line type. If you blinked when you read that scales map data both to position and colour, you are not alone. The notion that the same kind of object is used to map data to positions and symbols strikes some people as unintuitive. However, you will see the logic and power of this notion as you read further in the chapter.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2009 Springer-Verlag New York
About this chapter
Cite this chapter
Wickham, H. (2009). Scales, axes and legends. In: ggplot2. Use R. Springer, New York, NY. https://doi.org/10.1007/978-0-387-98141-3_6
Download citation
DOI: https://doi.org/10.1007/978-0-387-98141-3_6
Published:
Publisher Name: Springer, New York, NY
Print ISBN: 978-0-387-98140-6
Online ISBN: 978-0-387-98141-3
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)