shiftpoints: Calculate a shift for plotting overlapping points

View source: R/shiftpoints.R

shiftpointsR Documentation

Calculate a shift for plotting overlapping points

Description

Calculate a shift to add to overlapping points in plots for better visibility

Usage

shiftpoints(x, y, sh=( max(x)-min(x))/100, centered=TRUE, method=1, reg=6,
na.rm=TRUE)

Arguments

x

a data matrix or numeric vector for use in a plot.

y

a data matrix or numeric vector for use in a plot.

sh

the maximum total shift.

centered

logical, whether the shift is centered at 0, if FALSE the shift will be positive only.

method

numeric, can have the value 1 or 2, see Details.

reg

numeric, see Details.

na.rm

logical, indicating whether missing values should be removed.

Details

This function is similar to jitter but is defines for points in a two-dimensional plot. In contrast to jitter only the points with ties have a shift different from 0. The method to calculate the shift is therefore not based on random numbers.
If method=1 (default) the individual shift will be selected so that the shift range is sh, without regard of the number of overlapping points
method=2 means that for up to reg overlapping values a fixed shift of sh/reg is used

Value

Returns an array of shift values with the same dimension as x.

Author(s)

Ulrike Naumann and David Warton <David.Warton@unsw.edu.au>.

See Also

plot.mvabund , plot.mvformula, jitter.

Examples

shiftpoints( x=c(1:5, 1:10), y=c(2:6, 1:10) )

mvabund documentation built on March 18, 2022, 7:25 p.m.