avoid: Avoid overlaps

Description Usage Arguments Value Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)
abline(h = Im(mz), v = Re(mz), lwd = 0.5)
arrows(z, length=2.5, lwd = 0.5, gap = 1)
box()
text(z, pos = avoid(z), cex = 0.7, offset = 0.25,
     col = "red", font = 2, xpd = NA)

BillVenables/WWRGraphics documentation built on Feb. 1, 2021, 12:13 p.m.