Learn R Programming

MASSExtra (version 1.2.2)

avoid: Avoid overlaps

Description

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

Usage

avoid(x, ...)

# S4 method for 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 xy avoid(x, ...)

Value

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

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

Examples

Run this code
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)

Run the code above in your browser using DataLab