|
9 | 9 | for (nm in display) |
10 | 10 | xy[[nm]] <- scores(x, display = nm, choices = choices, ...) |
11 | 11 |
|
| 12 | + if (!missing(bg)) |
| 13 | + fill <- bg |
12 | 14 | if (length(display) > 1) { |
13 | 15 | ld <- length(display) |
14 | 16 | col <- rep(rep(col, length=ld), sapply(xy, nrow)) |
|
53 | 55 | } else { |
54 | 56 | labels <- rownames(xy) |
55 | 57 | } |
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 | | - } |
62 | 58 | em <- strwidth("m", cex = min(cex), font = min(font)) |
63 | 59 | ex <- strheight("x", cex = min(cex), font = min(font)) |
64 | 60 | ltr <- em*ex |
|
86 | 82 | j <- as.vector(as.dist(row(matrix(0, n, n)))) |
87 | 83 | k <- as.vector(as.dist(col(matrix(0, n, n)))) |
88 | 84 | ## 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 |
91 | 87 | ## ... and work only with those |
92 | 88 | j <- j[maylap] |
93 | 89 | k <- k[maylap] |
|
99 | 95 | ## behind 0.791: if you try n positions for n points, you try |
100 | 96 | ## 0.632*n labels, and if you try 0.791*n, you try half of labels |
101 | 97 | ## (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 |
105 | 101 | pos <- ifelse(xy[,2] > 0, 1, 3) |
106 | 102 | ## Criterion: overlap + penalty for moving towards origin and also |
107 | 103 | ## for corners. Penalty is mild: max 1 ltr and one-character |
|
0 commit comments