Skip to content

Commit ea73f4f

Browse files
committed
m
1 parent 5cd7ca7 commit ea73f4f

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: terra
22
Type: Package
33
Title: Spatial Data Analysis
4-
Version: 1.8-83
5-
Date: 2025-11-18
4+
Version: 1.8-85
5+
Date: 2025-11-23
66
Depends: R (>= 3.5.0), methods
77
Suggests: parallel, tinytest, ncdf4, sf (>= 0.9-8), deldir, XML, leaflet (>= 2.2.1), htmlwidgets
88
LinkingTo: Rcpp

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# version 1.8-83
1+
# version 1.8-85
22

33
## bug fixes
44

@@ -16,7 +16,7 @@
1616
- `boundaries` has new argument "ignoreNA=FALSE" to only detect boundaries between different classes, not between classes and missing values [#1963](https://github.com/rspatial/terra/issues/1963) by Oleg Zheleznyy
1717
- `stretch` gains argument "bylayer=TRUE" [#1970](https://github.com/rspatial/terra/issues/1970) by Michael Sumner
1818
- `makeValid` gains argument `buffer=FALSE` [#1955](https://github.com/rspatial/terra/issues/1955) by Márcia Barbosa
19-
- argument "col" in `plot<SpatVector>` can now be a named vector or two-column matrix/data.frame to match character/factor values to colors [#1976](https://github.com/rspatial/terra/issues/1976) by Richard Cooper
19+
- `plot<SpatVector>` argument "col" can now be a named vector or two-column matrix/data.frame to match character/factor values to colors [#1976](https://github.com/rspatial/terra/issues/1976) by Richard Cooper
2020

2121
## new
2222

R/plot_add.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@
4545

4646

4747

48-
add_legend <- function(x, y, ...) {
48+
add_legend <- function(x, y, xpd=TRUE, ...) {
4949
if (inherits(x, "character")) {
5050
e <- unlist(get.clip())
5151
if (!is.null(e)) {
52-
rct <- graphics::legend(x=x, y=y, plot=FALSE, ...)$rect
52+
rct <- graphics::legend(x=x, y=y, plot=FALSE, xpd=xpd, ...)$rect
5353
xy <- get_legxy(rct, e[1:4], x, NULL)
54-
graphics::legend(x=xy[1], y=xy[2], ...)
54+
graphics::legend(x=xy[1], y=xy[2], xpd=xpd, ...)
5555
} else {
56-
graphics::legend(x=x, y=y, ...)
56+
graphics::legend(x=x, y=y, xpd=xpd, ...)
5757
}
5858
} else {
59-
graphics::legend(x=x, y=y, ...)
59+
graphics::legend(x=x, y=y, xpd=xpd, ...)
6060
}
6161
}
6262

R/plot_raster.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@
156156
stopifnot(length(out$leg$legend) == length(out$levels))
157157
nlevs <- length(levs)
158158

159-
if (is.vector(out$cols) && !is.null(names(out$cols))) {
160-
out$cols <- data.frame(value=as.numeric(names(out$cols)), col=out$cols)
161-
}
159+
# if (is.vector(out$cols) && !is.null(names(out$cols))) {
160+
# out$cols <- data.frame(value=as.numeric(names(out$cols)), col=out$cols)
161+
# }
162162

163163
if (NCOL(out$cols) == 2) {
164164
#i <- match(Z, as.numeric(levs))

man/legend.Rd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ Wrapper around \code{\link[graphics]{legend}} that allows adding a custom legend
99
}
1010

1111
\usage{
12-
add_legend(x, y, ...)
12+
add_legend(x, y, xpd=xpd, ...)
1313
}
1414

1515

1616
\arguments{
1717
\item{x}{The keyword to be used to position the legend (or the x coordinate)}
1818
\item{y}{The y coordinate to be used to position the legend (is x is also a coordinate)}
19+
\item{xpd}{logical. If \code{TRUE}, the legend can be added outside the map area}
1920
\item{...}{arguments passed to \code{\link[graphics]{legend}}}
2021
}
2122

man/plot.Rd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ There is a separate help file for plotting a \code{\link[=plot,SpatGraticule,mis
5454
\arguments{
5555
\item{x}{SpatRaster or SpatVector}
5656
\item{y}{missing or positive integer or name indicating the layer(s) to be plotted}
57-
\item{col}{character vector to specify the colors to use. The default is \code{map.pal("viridis", 100)}. The default can be changed with the \code{terra.pal} option. For example: \code{options(terra.pal=terrain.colors(10))}. If \code{x} is a \code{SpatRaster} it can also be a \code{data.frame} with two columns (value, color) or a named vector (value=color) for a "classes" type legend or with three columns (from, to, color) for an "interval" type legend.
58-
If \code{x} is a \code{SpatVector} it can also be a \code{data.frame} with two columns (value, color) or a named vector (value=color) for a "classes" type legend. If \code{x} us a SpatVectorCollection, a list can be provided with colors for each SpatVector}
57+
\item{col}{character vector to specify the colors to use. The default is \code{map.pal("viridis", 100)}. The default can be changed with the \code{terra.pal} option. For example: \code{options(terra.pal=terrain.colors(10))}. If \code{x} is a \code{SpatRaster} it can also be a \code{data.frame} with two columns (value, color) for a "classes" type legend or with three columns (from, to, color) for an "interval" type legend. If \code{x} is a \code{SpatVector} it can also be a \code{data.frame} with two columns (value, color) or a named vector (value=color) for a "classes" type legend. If \code{x} us a SpatVectorCollection, a list can be provided with colors for each SpatVector}
5958
\item{type}{character. Type of map/legend. One of "continuous", "classes", or "interval". If not specified, the type is chosen based on the data}
6059
\item{mar}{numeric vector of length 4 to set the margins of the plot (to make space for the legend). The default is (3.1, 3.1, 2.1, 7.1) for a single plot with a legend and (3.1, 3.1, 2.1, 2.1) otherwise. The default for a RGB raster is 0. Use \code{mar=NA} to not set the margins}
6160
\item{legend}{logical or character. If not \code{FALSE} a legend is drawn. The character value can be used to indicate where the legend is to be drawn. For example "topright" or "bottomleft". Use \code{plg} for more refined placement. Not supported for continuous legends (the default for raster data)}

0 commit comments

Comments
 (0)