interpolation_transforms: Interpolation based scale transforms.

Description Usage Arguments Value Author(s) See Also Examples

Description

Interpolation based scale transformations. The user supplies x and y (which should be monotonic increasing or decreasing in x) to create a scale transformation based on linear interpolation.

A ‘warp’ transformation is also supported wherein the user supplies x and w where, after sorting on x, the cumulative sum of w are used as the y in an interpolation transformation. Here w are the rate of increase, or ‘weights’.

Usage

1
2
3

Arguments

x

the x coordinates for linear interpolation.

y

the y coordinates for linear interpolation.

data

A data.frame with columns of x and y for interp_trans or x and w for warp_trans. If data is given, it takes precedence over the given x, y, w.

na.rm

If TRUE, then missing x or y will be removed.

breaks

default breaks function for this transformation. The breaks function is applied to the raw data.

format

default format for this transformation. The format is applied to breaks generated to the raw data.

w

the w coordinates for the ‘warp’ interpolation. The cumulative sum of w are computed then fed to the interpolation transform.

Value

A scale transformation object.

Author(s)

Steven E. Pav shabbychef@gmail.com

See Also

trans_new.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
set.seed(1234)
ggplot(data.frame(x=rnorm(100),y=runif(100)),aes(x=x,y=y)) + 
  geom_point() + 
  scale_x_continuous(trans=interp_trans(x=seq(-10,10,by=1),y=cumsum(runif(21))))

set.seed(1234)
ggplot(data.frame(x=rnorm(100),y=runif(100)),aes(x=x,y=y)) + 
  geom_point() + 
  scale_x_continuous(trans=warp_trans(x=seq(-10,10,by=1),w=runif(21)))

# equivalently:
set.seed(1234)
ggplot(data.frame(x=rnorm(100),y=runif(100)),aes(x=x,y=y)) + 
  geom_point() + 
  scale_x_continuous(trans=warp_trans(data=data.frame(x=seq(-10,10,by=1),w=runif(21))))

# this is like trans_sqrt:
set.seed(1234)
myx <- seq(0,5,by=0.01)
ggplot(data.frame(x=rnorm(100),y=runif(100)),aes(x=x,y=y)) + 
  geom_point() + 
  scale_y_continuous(trans=interp_trans(x=myx,y=sqrt(myx)))

ggallin documentation built on May 1, 2019, 10:54 p.m.