## 11.1 Size

The size aesthetic is typically used to scale points and text. The default scale for size aesthetics is scale_size() in which a linear increase in the variable is mapped onto a linear increase in the area (not the radius) of the geom. Scaling as a function of area is a sensible default as human perception of size is more closely mimicked by area scaling than by radius scaling. By default the smallest value in the data (more precisely in the scale limits) is mapped to a size of 1 and the largest is mapped to a size of 6. The range argument allows you to scale the size of the geoms:

base <- ggplot(mpg, aes(displ, hwy, size = cyl)) +
geom_point()

base
base + scale_size(range = c(1, 2))  There are situations where area scaling is undesirable, and for such situations the scale_radius() function is provided. To illustrate when scale_radius() is appropriate consider a data set containing astronomical data that includes the radius of different planets:

planets
#>      name  type position radius    orbit
#> 1 Mercury Inner        1   2440 5.79e+07
#> 2   Venus Inner        2   6052 1.08e+08
#> 3   Earth Inner        3   6378 1.50e+08
#> 4    Mars Inner        4   3390 2.28e+08
#> 5 Jupiter Outer        5  71400 7.78e+08
#> 6  Saturn Outer        6  60330 1.43e+09
#> 7  Uranus Outer        7  25559 2.87e+09
#> 8 Neptune Outer        8  24764 4.50e+09

In this instance a plot that uses the size aesthetic to represent the radius of the planets should use scale_radius() rather than the default scale_size(). It is also important in this case to set the scale limits so that a planet with radius 0 would be drawn with a disc with radius 0.

base <- ggplot(planets, aes(1, name, size = radius)) +
geom_point() +
scale_x_continuous(breaks = NULL) +
labs(x = NULL, y = NULL, size = NULL)

base + ggtitle("not to scale")
base +
scale_radius(limits = c(0, NA), range = c(0, 10)) +
ggtitle("to scale")  On the left it is difficult to distinguish Jupiter from Saturn, despite the fact that the difference between the two should be double the size of Earth; compare this to the plot on the right where the radius of Jupiter is visibly larger.

Other size scales exist and are worth noting briefly:

• scale_size_binned() is a size scale that behaves like scale_size() but maps continuous values onto discrete size categories (analogous to the binned position and colour scales discussed earlier)

• scale_size_area() and scale_size_binned_area() are versions of scale_size() and scale_size_binned() that ensure that a value of 0 maps to an area of 0.

• scale_size_date() and scale_size_datetime() are designed to handle date data, analogous to the date scales discussed earlier.