Skip to content

Commit

Permalink
robustify key.pos handling
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Feb 14, 2024
1 parent 5b7e2e9 commit 9f4e45c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/plot.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
kw_dflt = function(x, key.pos) {
if (is.null(key.pos) || key.pos == 0) # no key:
if (is.null(key.pos) || key.pos[1] == 0) # no key:
return(lcm(0))

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

Expand Down

0 comments on commit 9f4e45c

Please sign in to comment.