avoid {MASSExtra}R Documentation

Avoid overlaps

Description

Generate a vector of positions to use to minimise text overlaps in labelled scatterplots

Usage

avoid(x, ...)

## S4 method for signature 'numeric'
avoid(
  x,
  y,
  ...,
  xlog = par("xlog"),
  ylog = par("ylog"),
  usr = par("usr"),
  pin = par("pin"),
  eps = .Machine$double.eps,
  pi = base::pi
)

## S4 method for signature 'xy'
avoid(x, ...)

Arguments

x, y

any of the forms that the coordinates of a scatterplot may be specified

...

additional arguments for methods

xlog, ylog

logicals: are the x- and/or y-scales logarithmic?

usr, pin

graphics parameters par("usr"), par("pin") (or replacements)

eps

numeric: a zero tolerance

pi

numeric: the value of the arithmetic constant of the same name

Value

a vector of integers all of which are 1, 2, 3, or 4, indicating placement positions.

Examples

set.seed(123)
z <- complex(real = runif(50), imaginary = runif(50))
mz <- mean(z)
z <- z[order(Arg(z - mz))]
plot(z, axes = FALSE, ann = FALSE)
segments(Re(mz), Im(mz), Re(z), Im(z))
abline(h = Im(mz), v = Re(mz), lwd = 0.5)
box()
text(Re(z), Im(z), pos = avoid(z), cex = 0.7, offset = 0.25,
     col = "red", font = 2, xpd = NA)

[Package MASSExtra version 1.2.2 Index]