position_identityx: adjust identity position which can be shifted vertically or...

View source: R/position_identityx.r

position_identityxR Documentation

adjust identity position which can be shifted vertically or horizontally.

Description

adjust identity position which can be shifted vertically or horizontally.

Usage

position_identityx(hexpand = NA, vexpand = NA)

Arguments

hexpand

numeric, distance to be shifted horizontally for geoms that have a position, default is NA.

vexpand

numeric, distance to be shifted vertically for geoms that have a position, default is NA.

Value

position method.

Author(s)

Shuangbin Xu

See Also

Other position adjustments: position_dodgex(), position_points_sinax()

Examples

library(ggplot2)
library(patchwork)
p <- ggplot(mtcars, aes(x=wt, y=mpg))
p1 <- p + geom_point(position=position_identityx()) + ylim(0, 50)
# whole point layer was shifted vertically (distance=5).
# the label of axis y should be subtracted 5 to get the true value..
p2 <- p + geom_point(position=position_identityx(vexpand=5)) + ylim(0, 50)
# whole point layer was shifted horizontally (distance=5).
# the label of axis x should be subtracted 5 to get the true value.
p3 <- ggplot(mtcars, aes(y=wt, x=mpg)) +
      geom_point(position=position_identityx(hexpand=5)) + xlim(0, 50)
p4 <- p1 + p2 + p3
p4

xiangpin/ggadd documentation built on Nov. 6, 2024, 11:04 p.m.