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, and then the inverse of the scale defines the total range of colors used in the mapping, which will be used to draw the legend of the graph.
Within a plot, each aesthetic assignment has a different scale, and each aesthetic attribute has a default...