ggbio (version 1.20.0)

rescale: rescale ggplot object

Description

Rescale a numeric vector or ggplot object, could be used for static zoom-in in ggbio.

Usage

"rescale"(x, to = c(0, 1), from = range(x, na.rm = TRUE))
"rescale"(x, xlim, ylim, sx = 1, sy = 1) "rescale"(x, xlim, ylim, sx = 1, sy = 1)

Arguments

x
A numeric object or ggplot object to be rescaled.
to
For numeric object. it's a vector of two numeric values, specifying the range to be rescale.
from
Range of x.
xlim
For ggplot object. This specify the new limits on x-scale.
ylim
For ggplot object. This specify the new limits on y-scale.
sx
Scale fold for x-scale. Default is 1, no change.
sy
Scale fold for y-scale. Default is 1, no change.

Value

Return the object of the same class as x after rescaling.

Details

When x is numeric value, it's just call scales::rescale, please refer to the manual page to check more details. If x is ggplot object, it first try to estimate current x limits and y limits of the ggplot object, then rescale based on those information.

Examples

Run this code
library(ggbio)
head(mtcars)
range(mtcars$mpg)
p <- qplot(data = mtcars, x = mpg, y = disp, geom = "point")
p.new <- rescale(p, xlim = c(20, 25))
p.new

Run the code above in your browser using DataCamp Workspace