Skip to content

Commit 9f4e45c

Browse files
committed
robustify key.pos handling
see r-spatial/stars#664
1 parent 5b7e2e9 commit 9f4e45c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

R/plot.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
kw_dflt = function(x, key.pos) {
2-
if (is.null(key.pos) || key.pos == 0) # no key:
2+
if (is.null(key.pos) || key.pos[1] == 0) # no key:
33
return(lcm(0))
44

55
font_scale = par("ps") / 12
6-
if (key.pos == -1)
6+
if (key.pos[1] == -1)
77
lcm(1.8 * font_scale)
8-
else if (key.pos %in% c(2, 4) && (is.character(x[[1]]) || is.factor(x[[1]]))) {
8+
else if (key.pos[1] %in% c(2, 4) && (is.character(x[[1]]) || is.factor(x[[1]]))) {
99
strings = if (is.factor(x[[1]]))
1010
levels(x[[1]])
1111
else
@@ -111,7 +111,7 @@ plot.sf <- function(x, y, ..., main, pal = NULL, nbreaks = 10, breaks = "pretty"
111111
if (ncol(x) > 2 && !isTRUE(dots$add)) { # multiple maps to plot...
112112
cols = setdiff(names(x), attr(x, "sf_column"))
113113
lt = .get_layout(st_bbox(x), min(max.plot, length(cols)), par("din"), key.pos[1], key.width)
114-
if (key.pos.missing || key.pos == -1)
114+
if (key.pos.missing || key.pos[1] == -1)
115115
key.pos = lt$key.pos
116116
layout(lt$m, widths = lt$widths, heights = lt$heights, respect = compact)
117117

0 commit comments

Comments
 (0)