Scales

Scales take care of the mapping of aesthetic attributes to the data. When the data is assigned to aesthetic mapping, the scales map the data to the corresponding aesthetic attribute, and this is done via a specific function depending on the scale applied. The inverse of this function is then used to map back the elements from the aesthetic to the actual value of the data. This process is used to create the axis, to represent the x-y position of the elements on the plot, or to create the legends that represent the mapping of other aesthetic attributes.

If, for instance, we consider the assignment of data to a color scale. First, the data is assigned to a color by mapping the value of the data to colors within the range defined by the scale, ...

Get ggplot2 Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.