spreadLabels2: Prevent overlapping labels

View source: R/spreadLabels2.R

spreadLabels2R Documentation

Prevent overlapping labels

Description

Determines clever placement of labels for plots made in base R

Usage

spreadLabels2(
  x,
  y,
  label,
  padding = 0,
  str.cex = par("cex"),
  str.font = par("font")
)

Arguments

x

The set of x coordinates for the points to plot

y

The set of y coordinates for the points to plot

label

A character vector of labels for each x,y pair.

padding

A numeric value representing the extra proportion of string size to add around each label. Not clear that this works as intended, so leave it at zero.

str.cex

The cex value for the label. Defaults to par("cex"). Passed to strwidth.

str.font

The font value for the label. Defaults to par("font"). Passed to strwidth.

Value

A matrix with 2 columns corresponding to x and y coordinates of the label centre to be used downstream as an input e.g. to text

References

This code is inspired by Federico Marini and Christoffer Flensburg.


BaderLab/scClustViz documentation built on Sept. 10, 2023, 11:51 p.m.