Generates a nice vector of labels by suppressing labels at certain positions. If a labelStep is given, only every labelStep-th label is considered. If a vector labpos of label positions and a minimum distance mindist of labels is given, it is guaranteed that the distance between labels to be shown is at least mindist.
niceLabels(label, labelstep = NULL, labelpos = NULL, mindist = 1, offset = 0)
label | vector of labels |
---|---|
labelstep | step width in which labels are to be printed, e.g. labelStep = 2 is used for plotting every second label. |
labelpos | label positions |
mindist | minimum distance between labels |
offset | offset by which the index of the first remaining label (default: 1) is shifted. Default: 0, i.e. the labels at indices 1, 1 + 1*labelstep, 1 + 2*labelstep, etc. remain. Offset = 1: the labels at indices 2, 2 + 1*labelstep, 2 + 2*labelstep, etc. remain. |
x <- matrix(1:12, nrow = 3) names.arg <- rep(1:4, each = 3) mybarplot <- function(x, ...) { barplot(x, horiz = TRUE, las = 1, beside = TRUE, ...) } mybarplot(x, names.arg = names.arg)