Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Oct 22, 2024
1 parent 807692f commit 122c038
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 5 additions & 7 deletions R/plot_legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,17 +409,15 @@ retro_labels <- function(x, lat=TRUE) {
legtitle <- x$leg$title[1]
}
e <- x$leg$ext
if (length(legtitle) > 1) {
if (length(legtitle) > 1) { # or perhaps !inherits(legtitle, "expression")
if (x$leg$x %in% c("top", "bottom")) {
txt <- paste(legtitle, collapse=" ")
legtitle <- paste(legtitle, collapse=" ")
} else {
txt <- paste(legtitle, collapse="\n")
legtitle <- paste(legtitle, collapse="\n")
}
} else {
txt <- legtitle
}
}
# offset=.5*graphics::strheight("a",cex=x$leg$title.cex)
text(x=e$xmax, y=e$ymax, labels=txt, pos=3, cex=x$leg$title.cex, xpd=NA)
text(x=e$xmax, y=e$ymax, labels=legtitle, pos=3, cex=x$leg$title.cex, xpd=NA)
}
x
}
Expand Down
3 changes: 3 additions & 0 deletions src/raster_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ SpatRaster SpatRaster::weighted_mean(SpatRaster w, bool narm, SpatOptions &opt)
w = w.mask(*this, false, NAN, NAN, topt);
}
SpatRaster wsum = w.summary("sum", narm, topt);
if (opt.names.empty()) {
opt.names = {"weighted.mean"};
}
return out.arith(wsum, "/", false, opt);
}

Expand Down

0 comments on commit 122c038

Please sign in to comment.