get_gg_label: Checking Min, Max, Labels and Label Positions

Description Usage Arguments Examples

View source: R/get_gg_label.R

Description

Given a numeric vector or a ggplot object, the function will check the range, labels and label positions (the same as major grid lines) that will used on the axis. The result is a length 5 list for min limit, max limit, labels, major grid-line positions, all (major and minor) grid-line positions.

Usage

1
2
3
4
5
6
7
8
9
get_gg_label(
  a = NULL,
  b = NULL,
  v = NULL,
  gg = NULL,
  mult = 0.05,
  add = 0,
  axis = "y"
)

Arguments

a

extreme values of a numeric vector. Note: only one of a, v, gg can be non-NULL. It can also be a gg object.

b

another extreme value if a is not NULL.

v

a numeric vector.

gg

a gg object created by ggplot function. Which value will be checked depends on axis.

mult

default is 0.05 and should be of length 1 or 2. It mimics the mult argument of ggplot2::expansion. It is only used when a is numeric or v is non-NULL.

add

default is 0. It mimics the add argument of ggplot2::expansion.

axis

if gg is used or a is a ggplot object, which axis will be checked? It can be "x" or "y" (default).

Examples

1
2
3
4
5
6
7
get_gg_label(a=1, b=1000)
# The following three have the same results.
get_gg_label(a=1, b=1000, mult=0)
get_gg_label(v=c(1, 500, 1000), mult=0)
p=ggplot()+geom_point(aes(1: 3, c(1, 500, 1000)))+
  scale_y_continuous(expand=expansion(mult=0))
get_gg_label(gg=p)

plothelper documentation built on July 2, 2020, 4:03 a.m.