Skip to content

Commit

Permalink
fixes #1532
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Jun 16, 2024
1 parent 620d1ca commit 5cea787
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
31 changes: 31 additions & 0 deletions R/plot_vector.R
Original file line number Diff line number Diff line change
Expand Up @@ -752,3 +752,34 @@ setMethod("plot", signature(x="SpatVectorProxy", y="missing"),
}
)



setMethod("plot", signature(x="SpatVectorCollection", y="missing"),
function(x, y, main, mar=NULL, nc, nr, maxnl=16, ...) {
nl <- max(1, min(length(x), maxnl))

if (nl==1) {
if (missing(main)) main = ""
out <- plot(x, 1, maxcell=maxcell, main=main[1], mar=mar, add=add, ...)
return(invisible(out))
}

nrnc <- .get_nrnc(nr, nc, nl)
old.par <- graphics::par(no.readonly = TRUE)
on.exit(graphics::par(old.par))
if (is.null(mar)) {
mar=c(1.5, 1, 2.5, 3)
}
graphics::par(mfrow=nrnc)

if (missing("main")) {
main <- names(x)
} else {
main <- rep_len(main, nl)
}
for (i in 1:nl) {
plot(x[i], main=main[i], mar=mar, ...)
}
}
)

5 changes: 5 additions & 0 deletions man/plot.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
\alias{plot,SpatVector,data.frame-method}
\alias{plot,SpatVector,character-method}
\alias{plot,SpatVectorProxy,missing-method}
\alias{plot,SpatVectorCollection,missing-method}



\title{Make a map}

Expand Down Expand Up @@ -42,6 +45,8 @@ There is a separate help file for plotting a \code{\link[=plot,SpatGraticule,mis
\S4method{plot}{SpatVector,numeric}(x, y, ...)

\S4method{plot}{SpatVector,missing}(x, y, values=NULL, ...)

\S4method{plot}{SpatVectorCollection,missing}(x, y, main, mar=NULL, nc, nr, maxnl=16, ...)
}

\arguments{
Expand Down

0 comments on commit 5cea787

Please sign in to comment.