The default is scales::oob_censor() which replaces any value outside the limits with NA. You can override this default by setting oob argument of the scale, a function that is applied to all observations outside the scale limits. This can occasionally lead to unexpected behaviour, as illustrated in Section 10.1.2. The default behaviour in ggplot2 is to convert out of bounds values to NA, the logic for this being that if a data value is not part of the mapped region, it should be treated as missing. This leads naturally to the question of what ggplot2 should do if the data set contains “out of bounds” values that fall outside the limits. The toolbox chapters outline the common practical goals for specifying the limits: for position scales the limits are used to set the end points of the axis, for example. For discrete scales, however, the data space is unstructured and consists only of a set of categories: as such the limits for a discrete scale can only be specified by enumerating the set of categories over which the mapping is defined. For continuous and binned scales, the data space is inherently continuous and one-dimensional, so the limits can be specified by two end points. At a theoretical level this region is defined differently depending on the fundamental scale type. Scale limits are an extension of this idea: they dictate the region of the data space over which the mapping is defined. Section 15.1 introduced the concept that a scale defines a mapping from the data space to the aesthetic space.
0 Comments
Leave a Reply. |