|
374 | 374 | old.mar <- graphics::par()$mar |
375 | 375 | if (!any(is.na(x$mar))) { graphics::par(mar=x$mar) } |
376 | 376 | if (x$reset) on.exit(graphics::par(mar=old.mar)) |
| 377 | + |
| 378 | + if (x$zebra) { |
| 379 | + width <- rep(min(diff(x$lim[1:2]), diff(x$lim[3:4])) / 100, 2) * x$zebra.cex |
| 380 | + if (x$lonlat) { |
| 381 | + asp <- 1/cos((mean(x$lim[3:4]) * pi)/180) |
| 382 | + width[2] <- width[2] / asp |
| 383 | + } |
| 384 | + x$lim[1:2] <- x$lim[1:2] + c(-width[1], width[1]) |
| 385 | + x$lim[3:4] <- x$lim[3:4] + c(-width[2], width[2]) |
| 386 | + } |
| 387 | + |
377 | 388 | arglist <- c(list(x=x$lim[1:2], y=x$lim[3:4], type="n", xlab="", ylab="", asp=x$asp, xaxs=x$xaxs, yaxs=x$yaxs, axes=FALSE), x$dots) |
378 | 389 | do.call(plot, arglist) |
379 | 390 | if (!is.null(x$background)) { |
|
387 | 398 | if (!x$legend_only) { |
388 | 399 | graphics::rasterImage(x$r, x$ext[1], x$ext[3], x$ext[2], x$ext[4], angle = 0, interpolate = x$interpolate) |
389 | 400 | x <- .plot.axes(x) |
| 401 | + if (x$zebra) { |
| 402 | + try(set.clip(x$lim, x$lonlat)) |
| 403 | + zebra(width=width, x=x$axs$xat, y=x$axs$yat) |
| 404 | + x$lim[1:2] <- x$lim[1:2] + c(width[1], -width[1]) |
| 405 | + x$lim[3:4] <- x$lim[3:4] + c(width[2], -width[2]) |
| 406 | + } |
390 | 407 | } |
391 | 408 |
|
392 | 409 | if (x$legend_draw) { |
|
442 | 459 | xlab="", ylab="", cex.lab=0.8, line.lab=1.5, asp=NULL, yaxs="i", xaxs="i", |
443 | 460 | main="", cex.main=1.2, line.main=0.5, font.main=graphics::par()$font.main, col.main = graphics::par()$col.main, loc.main=NULL, |
444 | 461 | sub = "", font.sub=1, cex.sub=0.8*cex.main, line.sub =1.75, col.sub=col.main, loc.sub=NULL, |
445 | | - halo=FALSE, hc="white", hw=0.1, axes=TRUE, box=TRUE, maxcell=500000, buffer=FALSE, clip=TRUE, |
| 462 | + halo=FALSE, hc="white", hw=0.1, axes=TRUE, box=TRUE, zebra=FALSE, zebra.cex=1, maxcell=500000, buffer=FALSE, clip=TRUE, |
446 | 463 | # for rgb |
447 | 464 | stretch=NULL, scale=NULL, bgalpha=NULL, zlim=NULL, zcol=NULL, overview=NULL, |
448 | 465 | #catch and kill |
|
610 | 627 | } |
611 | 628 | out$leg$reverse <- isTRUE(reverse) |
612 | 629 | out$box <- isTRUE(box) |
| 630 | + out$zebra <- isTRUE(zebra) |
| 631 | + out$zebra.cex <- zebra.cex |
613 | 632 |
|
614 | 633 | # if (!is.null(out$leg$loc)) { |
615 | 634 | # out$leg$x <- out$leg$loc |
|
674 | 693 |
|
675 | 694 |
|
676 | 695 | setMethod("plot", signature(x="SpatRaster", y="numeric"), |
677 | | - function(x, y=1, col, type=NULL, mar=NULL, legend=TRUE, axes=!add, plg=list(), pax=list(), maxcell=500000, smooth=FALSE, range=NULL, fill_range=FALSE, levels=NULL, all_levels=FALSE, breaks=NULL, breakby="eqint", fun=NULL, colNA=NULL, alpha=NULL, sort=FALSE, reverse=FALSE, grid=FALSE, ext=NULL, reset=FALSE, add=FALSE, buffer=FALSE, background=NULL, box=axes, clip=TRUE, overview=NULL, ...) { |
| 696 | + function(x, y=1, col, type=NULL, mar=NULL, legend=TRUE, axes=!add, plg=list(), pax=list(), maxcell=500000, smooth=FALSE, range=NULL, fill_range=FALSE, levels=NULL, all_levels=FALSE, breaks=NULL, breakby="eqint", fun=NULL, colNA=NULL, alpha=NULL, sort=FALSE, reverse=FALSE, grid=FALSE, zebra=FALSE, ext=NULL, reset=FALSE, add=FALSE, buffer=FALSE, background=NULL, box=axes, clip=TRUE, overview=NULL, ...) { |
678 | 697 |
|
679 | 698 | old.mar <- graphics::par()$mar |
680 | 699 | on.exit(graphics::par(mar=old.mar)) |
@@ -703,7 +722,7 @@ setMethod("plot", signature(x="SpatRaster", y="numeric"), |
703 | 722 | alpha <- alpha[[y]] |
704 | 723 | } |
705 | 724 | } |
706 | | - plot(x, col=col, type=type, mar=mar, legend=legend, axes=axes, plg=plg, pax=pax, maxcell=2*maxcell/length(y), smooth=smooth, range=range, fill_range=fill_range, levels=levels, all_levels=all_levels, breaks=breaks, breakby=breakby, fun=fun, colNA=colNA, alpha=alpha, grid=grid, sort=sort, reverse=reverse, ext=ext, reset=reset, add=add, buffer=buffer, background=background, box=box, clip=clip, overview=overview, ...) |
| 725 | + plot(x, col=col, type=type, mar=mar, legend=legend, axes=axes, plg=plg, pax=pax, maxcell=2*maxcell/length(y), smooth=smooth, range=range, fill_range=fill_range, levels=levels, all_levels=all_levels, breaks=breaks, breakby=breakby, fun=fun, colNA=colNA, alpha=alpha, zebra=zebra, grid=grid, sort=sort, reverse=reverse, ext=ext, reset=reset, add=add, buffer=buffer, background=background, box=box, clip=clip, overview=overview, ...) |
707 | 726 | return(invisible()) |
708 | 727 | } else { |
709 | 728 | x <- x[[y]] |
@@ -779,7 +798,7 @@ setMethod("plot", signature(x="SpatRaster", y="numeric"), |
779 | 798 | } |
780 | 799 | } |
781 | 800 |
|
782 | | - x <- .prep.plot.data(x, type=type, cols=col, mar=mar, draw=TRUE, plg=plg, pax=pax, legend=isTRUE(legend), axes=isTRUE(axes), coltab=coltab, cats=cats, interpolate=smooth, levels=levels, range=range, fill_range=fill_range, colNA=colNA, alpha=alpha, reset=reset, grid=grid, sort=sort, reverse=reverse, ext=ext, all_levels=all_levels, breaks=breaks, breakby=breakby, add=add, buffer=buffer, background=background, box=box, maxcell=maxcell, clip=clip, overview=overview, ...) |
| 801 | + x <- .prep.plot.data(x, type=type, cols=col, mar=mar, draw=TRUE, plg=plg, pax=pax, legend=isTRUE(legend), axes=isTRUE(axes), coltab=coltab, cats=cats, interpolate=smooth, levels=levels, range=range, fill_range=fill_range, colNA=colNA, alpha=alpha, reset=reset, grid=grid, zebra=zebra, sort=sort, reverse=reverse, ext=ext, all_levels=all_levels, breaks=breaks, breakby=breakby, add=add, buffer=buffer, background=background, box=box, maxcell=maxcell, clip=clip, overview=overview, ...) |
783 | 802 |
|
784 | 803 | add_more(fun, y) |
785 | 804 |
|
|
0 commit comments