calcOffsetGridText-deprecated: Calculate offset coordinates for grid-based text annotations

Description Usage Arguments Value Author(s) See Also Examples

Description

Calculate offset coordinates for (grid-based) text drawing functions, e.g. grid.text.

Usage

1
2
calcOffsetGridText(x, y = NULL, offset = 0.02, pos = NULL
, xlim = NULL, ylim = NULL)

Arguments

x

Numeric. A vector containing x coordinates, or a 2-column matrix containing x and y coordinates.

y

Numeric. A vector containing y coordinates, or NULL if x is a two-column matrix.

offset

Numeric. The desired offset in normalized parent coordinates ("npc", see unit).

pos

Integer. Text position specifier(s) as used by text. If not supplied, optimal text positions will be determined with respect to neighboring locations using thigmophobe.

xlim

Numeric. X-axis limits (xmin, xmax) of the current plot. If not supplied, limits are automatically calculated from supplied x and y coordinates.

ylim

Numeric. Y-axis limits (ymin, ymax) of the current plot. If not supplied, limits are automatically calculated from supplied x and y coordinates.

Value

A numeric matrix containing offset coordinates.

Author(s)

Florian Detsch

See Also

Rsenal-deprecated

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Not run: 
# required packages
library(grid)
library(plotrix)
library(lattice)

# sample point data
x_cntr <- 330000
y_cntr <- 9650000

ls_xy <- lapply(c(x_cntr, y_cntr), function(i) {
  set.seed(i * 100)
  rnorm(10, i, 10000)
})

df <- data.frame(id = 1:10,
                 x = ls_xy[[1]],
                 y = ls_xy[[2]])
coordinates(df) <- ~ x + y
projection(df) <- "+init=epsg:21037"

# offset point locations
loc_lbl <- calcOffsetGridText(x = coordinates(df), offset = .015)

# vis
spplot(df, col.regions = "black", auto.key = FALSE)

downViewport(trellis.vpname(name = "figure"))
for (i in 1:nrow(df))
  grid.text(label = df$id[i], x = loc_lbl[i, 1], y = loc_lbl[i, 2],
            just = pos2just(thigmophobe(coordinates(df)))[i])

## End(Not run)
            

environmentalinformatics-marburg/Rsenal documentation built on Sept. 23, 2018, 5:17 a.m.