Skip to content

Commit

Permalink
add expandBB argument, to expand the bbox of object plotted
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Feb 3, 2016
1 parent 5229957 commit d650459
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions R/Spatial-methods.R
Expand Up @@ -210,13 +210,15 @@ bb2merc = function(x, cls = "ggmap") { # return bbox in the appropriate "web mer

plot.Spatial <- function(x, xlim = NULL, ylim = NULL,
asp = NA, axes = FALSE, bg = par("bg"), ...,
xaxs, yaxs, lab, setParUsrBB = FALSE, bgMap = NULL) {
xaxs, yaxs, lab, setParUsrBB = FALSE, bgMap = NULL, expandBB = c(0,0,0,0)) {

# expandBB: 1=below, 2=left, 3=above and 4=right.
bbox <- bbox(x)
expBB = function(lim, expand) c(lim[1] - expand[1] * diff(lim), lim[2] + expand[2] * diff(lim))
if (is.null(xlim))
xlim <- bbox[1,]
xlim <- expBB(bbox[1,], expandBB[c(2,4)])
if (is.null(ylim))
ylim <- bbox[2,]
ylim <- expBB(bbox[2,], expandBB[c(1,3)])
if (is.na(asp))
asp <- ifelse(is.na(proj4string(x)) || is.projected(x), 1.0,
1/cos((mean(ylim) * pi)/180))
Expand Down

0 comments on commit d650459

Please sign in to comment.