inter_ticks
inter_ticks.Rd
Define coordinates and values of secondary ticks.
Usage
inter_ticks(
lim,
log = "log10",
breaks = NULL,
n = NULL,
warn.print = TRUE,
safer_check = TRUE
)
Arguments
- lim
Vector of 2 numbers indicating the limit range of the axis. Order of the 2 values matters (for inverted axis). If log argument is "log2" or "log10", values in lim must be already log transformed. Thus, negative or zero values are allowed.
- log
Single character string. Either "log2" (values in the lim argument are log2 transformed) or "log10" (values in the lim argument are log10 transformed), or "no".
- breaks
Mandatory vector of numbers indicating the main ticks values/positions when log argument is "no". Ignored when log argument is "log2" or "log10".
- n
Single numeric value indicating the number of secondary ticks between each main tick when log argument is "no". Ignored when log argument is "log2" or "log10".
- warn.print
Single logical value. Print potential warning messages at the end of the execution? If FALSE, warning messages are never printed, but can still be recovered in the returned list.
- safer_check
Single logical value. Perform some "safer" checks (see https://github.com/safer-r)? If TRUE, checkings are performed before main code running: 1) R classical operators (like "<-") not overwritten by another package because of the R scope and 2) required functions and related packages effectively present in local R lybraries. Set to FALSE if this fonction is used inside another "safer" function to avoid pointless multiple checkings.
Value
A list containing :
- $log: value of the log argument used.
- $coordinates: the coordinates of the secondary ticks on the axis, between the lim values.
- $values: the corresponding values associated to each coordinate (with log scale, 2^$values or 10^$values is equivalent to the labels of the axis).
- $warn: the potential warning messages. Use cat() for proper display. NULL if no warning.
Author
Gael Millot <gael.millot@pasteur.fr>
Yushi Han <yushi.han2000@gmail.com>
Haiding Wang <wanghaiding442@gmail.com>
Examples
# no log scale
inter_ticks(lim = c(-4,4), log = "no", breaks = c(-2, 0, 2), n = 3)
#> $log
#> [1] "no"
#>
#> $coordinates
#> [1] -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0
#> [16] 3.5 4.0
#>
#> $values
#> [1] -4.0 -3.5 -3.0 -2.5 -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0
#> [16] 3.5 4.0
#>
#> $warn
#> NULL
#>
inter_ticks(lim = c(10, 0), log = "no", breaks = c(10, 8, 6, 4, 2, 0), n = 4)
#> $log
#> [1] "no"
#>
#> $coordinates
#> [1] 10.0 9.6 9.2 8.8 8.4 8.0 7.6 7.2 6.8 6.4 6.0 5.6 5.2 4.8 4.4
#> [16] 4.0 3.6 3.2 2.8 2.4 2.0 1.6 1.2 0.8 0.4 0.0
#>
#> $values
#> [1] 10.0 9.6 9.2 8.8 8.4 8.0 7.6 7.2 6.8 6.4 6.0 5.6 5.2 4.8 4.4
#> [16] 4.0 3.6 3.2 2.8 2.4 2.0 1.6 1.2 0.8 0.4 0.0
#>
#> $warn
#> NULL
#>
# log2
inter_ticks(lim = c(-4,4), log = "log2")
#> $log
#> [1] "log2"
#>
#> $coordinates
#> [1] -4.0000000 -3.4150375 -3.0000000 -2.6780719 -2.4150375 -2.1926451
#> [7] -2.0000000 -1.8300750 -1.6780719 -1.4150375 -1.1926451 -1.0000000
#> [13] -0.8300750 -0.6780719 -0.4150375 -0.1926451 0.0000000 0.1699250
#> [19] 0.3219281 0.5849625 0.8073549 1.0000000 1.1699250 1.3219281
#> [25] 1.5849625 1.8073549 2.0000000 2.1699250 2.3219281 2.5849625
#> [31] 2.8073549 3.0000000 3.1699250 3.3219281 3.5849625 3.8073549
#> [37] 4.0000000
#>
#> $values
#> [1] 0.06250 0.09375 0.12500 0.15625 0.18750 0.21875 0.25000 0.28125
#> [9] 0.31250 0.37500 0.43750 0.50000 0.56250 0.62500 0.75000 0.87500
#> [17] 1.00000 1.12500 1.25000 1.50000 1.75000 2.00000 2.25000 2.50000
#> [25] 3.00000 3.50000 4.00000 4.50000 5.00000 6.00000 7.00000 8.00000
#> [33] 9.00000 10.00000 12.00000 14.00000 16.00000
#>
#> $warn
#> NULL
#>
# log10
inter_ticks(lim = c(-2,3), log = "log10")
#> $log
#> [1] "log10"
#>
#> $coordinates
#> [1] -2.00000000 -1.69897000 -1.52287875 -1.39794001 -1.30103000 -1.22184875
#> [7] -1.15490196 -1.09691001 -1.04575749 -1.00000000 -0.69897000 -0.52287875
#> [13] -0.39794001 -0.30103000 -0.22184875 -0.15490196 -0.09691001 -0.04575749
#> [19] 0.00000000 0.30103000 0.47712125 0.60205999 0.69897000 0.77815125
#> [25] 0.84509804 0.90308999 0.95424251 1.00000000 1.30103000 1.47712125
#> [31] 1.60205999 1.69897000 1.77815125 1.84509804 1.90308999 1.95424251
#> [37] 2.00000000 2.30103000 2.47712125 2.60205999 2.69897000 2.77815125
#> [43] 2.84509804 2.90308999 2.95424251 3.00000000
#>
#> $values
#> [1] 1e-02 2e-02 3e-02 4e-02 5e-02 6e-02 7e-02 8e-02 9e-02 1e-01 2e-01 3e-01
#> [13] 4e-01 5e-01 6e-01 7e-01 8e-01 9e-01 1e+00 2e+00 3e+00 4e+00 5e+00 6e+00
#> [25] 7e+00 8e+00 9e+00 1e+01 2e+01 3e+01 4e+01 5e+01 6e+01 7e+01 8e+01 9e+01
#> [37] 1e+02 2e+02 3e+02 4e+02 5e+02 6e+02 7e+02 8e+02 9e+02 1e+03
#>
#> $warn
#> NULL
#>