| calcOffsetGridText-deprecated | R Documentation | 
Calculate offset coordinates for (grid-based) text drawing 
functions, e.g. grid.text.
calcOffsetGridText(x, y = NULL, offset = 0.02, pos = NULL
, xlim = NULL, ylim = NULL)
| 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  | 
| offset | Numeric. The desired offset in normalized parent coordinates
("npc", see  | 
| pos | Integer. Text position specifier(s) as used by  | 
| 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. | 
A numeric matrix containing offset coordinates.
Florian Detsch
Rsenal-deprecated
## 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)
            
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.