Visual range expansion
The visual range of the axes actually extends a little bit past the numeric limits that we have specified.
Override the defaults setting with
expand()
argument wich expects a numeric vector.For example, one case where it’s usually preferable to remove this space is when using geom_raster(), which we can achieve by setting
expand = expansion(0)
:
expand
argument: For position scales, a vector of range expansion constants used to add some padding around the data to ensure that they are placed some distance away from the axes. Use the convenience function expansion() to generate the values for the expand argument. The defaults are to expand the scale by 5% on each side for continuous variables, and by 0.6 units on each side for discrete variables.With
expansion()
.Additive factor: specifies a constant space added to outside of the nominal axis limits.
Multiplicative factor: adds space defined as a proportion of the size of the axis limit.
These correspond to the add and mult arguments to expansion(), which can be length one (if the expansion is the same on both sides) or length two (to set different expansions on each side).
The
add
argument is specified on the same scale as the data variable, whereas themult
argument is specified relative to the axis range.
## $mult
## [1] 0
##
## $add
## [1] 0