Skip to content

Commit 5beba08

Browse files
committed
ordipointlabel can "optimize" < 3 labels
1 parent 70df875 commit 5beba08

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

R/ordipointlabel.R

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
for (nm in display)
1010
xy[[nm]] <- scores(x, display = nm, choices = choices, ...)
1111

12+
if (!missing(bg))
13+
fill <- bg
1214
if (length(display) > 1) {
1315
ld <- length(display)
1416
col <- rep(rep(col, length=ld), sapply(xy, nrow))
@@ -53,12 +55,6 @@
5355
} else {
5456
labels <- rownames(xy)
5557
}
56-
## our algorithm needs at least three items
57-
if (nrow(xy) < 3) {
58-
warning(gettextf("optimization needs at least three items, you got %d",
59-
nrow(xy)))
60-
return(invisible(x))
61-
}
6258
em <- strwidth("m", cex = min(cex), font = min(font))
6359
ex <- strheight("x", cex = min(cex), font = min(font))
6460
ltr <- em*ex
@@ -86,8 +82,8 @@
8682
j <- as.vector(as.dist(row(matrix(0, n, n))))
8783
k <- as.vector(as.dist(col(matrix(0, n, n))))
8884
## Find labels that may overlap...
89-
maylap <- overlap(xy[j,], 2*box[j,] - c(em,ex)/1.5,
90-
xy[k,], 2*box[k,] - c(em,ex)/1.5) > 0
85+
maylap <- overlap(xy[j,,drop=FALSE], 2*box[j,,drop=FALSE] - c(em,ex)/1.5,
86+
xy[k,,drop=FALSE], 2*box[k,,drop=FALSE] - c(em,ex)/1.5) > 0
9187
## ... and work only with those
9288
j <- j[maylap]
9389
k <- k[maylap]

0 commit comments

Comments
 (0)