Skip to content

Commit 1e8f0dc

Browse files
committed
Merge branch 'nothing-to-optimize'
2 parents 73da430 + 5beba08 commit 1e8f0dc

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

R/ordipointlabel.R

Lines changed: 7 additions & 11 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]
@@ -99,9 +95,9 @@
9995
## behind 0.791: if you try n positions for n points, you try
10096
## 0.632*n labels, and if you try 0.791*n, you try half of labels
10197
## (some repeatedly).
102-
nit <- min(64 * length(jk), 10000) # default 10000
103-
temp <- 5 # default 10
104-
tmax <- ceiling(0.791 * length(jk)) # default 10
98+
nit <- min(64 * length(jk), 10000) # default 10000
99+
temp <- 5 # default 10
100+
tmax <- max(1, ceiling(0.791 * length(jk))) # default 10
105101
pos <- ifelse(xy[,2] > 0, 1, 3)
106102
## Criterion: overlap + penalty for moving towards origin and also
107103
## for corners. Penalty is mild: max 1 ltr and one-character

0 commit comments

Comments
 (0)