Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed May 22, 2024
1 parent b7a869c commit 79ff397
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- `inset` has new arguments "offset" and "add" [#1422](https://github.com/rspatial/terra/issues/1422) by Armand-CT
- `expanse<SpatRaster>` has argument `usenames` [#1446](https://github.com/rspatial/terra/issues/1446) by Bappa Das
- the default color palette is now `terra::map.pal("viridis")` instead of `terrain.colors`. The default can be changes with `options(terra.pal=...)` [#1474](https://github.com/rspatial/terra/issues/1474) by Derek Friend
- `as.list<SpatRasterDataset>` now returns a named list. [#1513](https://github.com/rspatial/terra/issues/1513) by Eric R. Scott


## new
Expand Down
10 changes: 5 additions & 5 deletions R/plot_legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -508,13 +508,13 @@ add_box <- function(...) {

add_grid <- function(nx=NULL, ny=nx, col="lightgray", lty="dotted", lwd=par("lwd")) {

p <- terra:::get.clip()
p <- terra::get.clip()

## adapted from graphics::grid
g.grid.at <- function (side, n, axp, usr2) {
if (is.null(n)) {
stopifnot(is.numeric(ax <- axp), length(ax) == 3L)
axTicks(side, axp=ax, usr=usr2, log=FALSE)
graphics::axTicks(side, axp=ax, usr=usr2, log=FALSE)
}
else if (!is.na(n) && (n <- as.integer(n)) >= 1L) {
at <- seq.int(usr2[1L], usr2[2L], length.out = n + 1L)
Expand All @@ -523,10 +523,10 @@ add_grid <- function(nx=NULL, ny=nx, col="lightgray", lty="dotted", lwd=par("lwd
}

atx <- if (is.null(nx) || (!is.na(nx) && nx >= 1))
g.grid.at(1L, nx, axp = par("xaxp"), usr2 = p[1:2])
g.grid.at(1L, nx, axp = graphics::par("xaxp"), usr2 = p[1:2])
aty <- if (is.null(ny) || (!is.na(ny) && ny >= 1))
g.grid.at(2L, ny, axp = par("yaxp"), usr2 = p[3:4])
abline(v = atx, h = aty, col = col, lty = lty, lwd = lwd)
g.grid.at(2L, ny, axp = graphics::par("yaxp"), usr2 = p[3:4])
graphics::abline(v = atx, h = aty, col = col, lty = lty, lwd = lwd)
invisible(list(atx = atx, aty = aty))
}

Expand Down

0 comments on commit 79ff397

Please sign in to comment.