concept scale in category R

This is an excerpt from Manning's book Beyond Spreadsheets with R.
Measurements are composed of two parts: a value and a scale. We may tend to abbreviate this when we talk (“I was driving at 60”), but this only makes sense if we assume everyone is familiar with the units (was that kilometers per hour or miles per hour?). You may store population counts on the scale of “millions of people,” but the value you use may be only
318.9.
Figure 9.40 You can extend the scale to a not-yet-present fourth level.
![]()
This usage of
limitsdiffers somewhat from the usage inscale_x_continuous(). The help file forscale_x_discrete()notes that the meaning of the argumentlimitsis “A character vector that defines possible values of the scale and their order.” That’s what you've provided — a character vector (due toas.character()) of the values to be used on the x-axis, and their order. These arec("2", "4", "6", "8").
Some of the groups don’t have many values, so it’s sometimes useful to be able to change the scale. You need to change it differently for each facet, though, so that option is built right in as the
scalesargument, which takes a"free"value to make the scaling independent for each facet (shown in figure 9.49):ggplot(mtcars, aes(mpg, disp, col = factor(carb))) + geom_point() + facet_wrap(~ carb, scales = "free")Figure 9.49 Using
scales = "free"means the scale in each facet panel is independent.![]()
Figure 9.50 You can keep only one axis fixed using
scales = "free_x".![]()