Skip to content

Commit d4ff30d

Browse files
committed
plot_crowns() [WIP] make graphics params more configurable
1 parent 0a7b587 commit d4ff30d

2 files changed

Lines changed: 23 additions & 14 deletions

File tree

R/plot_crowns.R

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@
2626
#' given in meters, and tree diameters are assumed to be given in centimeters.
2727
#' **TODO: not currently implemented**
2828
#' @param main Character string giving the main plot title (on top).
29-
#' @param crown_col The color of tree crowns.
29+
#' @param crown_col The color of tree crowns, e.g., either a color name (as
30+
#' listed by `colors()`) or a hexadecimal string.
3031
#' @param stem_col The color of tree stems when plotting an individual subplot
31-
#' or microplot.
32-
#' @param subp_border_lwd The line width of subplot boundaries, a _positive_
33-
#' number, defaulting to `3`.
32+
#' or microplot (see `crown_col` above).
33+
#' @param subp_border_lwd The line width of subplot boundaries. Must a positive
34+
#' number.
35+
#' @param subp_border_col The color of subplot boundaries (see `crown_col`
36+
#' above).
3437
#' @return
3538
#' The input, invisibly.
3639
#'
@@ -46,7 +49,8 @@
4649
#' @export
4750
plot_crowns <- function(tree_list, subplot = NULL, microplot = FALSE,
4851
linear_unit = "ft", main = "", crown_col = "#328e13",
49-
stem_col = "#b85e00", subp_border_lwd = 3){
52+
stem_col = "#b85e00", subp_border_lwd = 3,
53+
subp_border_col = "gray62"){
5054

5155
if (missing(tree_list) || is.null(tree_list))
5256
stop("'tree_list' is required", call. = FALSE)
@@ -139,7 +143,7 @@ plot_crowns <- function(tree_list, subplot = NULL, microplot = FALSE,
139143

140144
xlab <- sprintf("x (%s)", linear_unit)
141145
ylab <- sprintf("y (%s)", linear_unit)
142-
gdalraster::plot_geom(fia_poly, xlab, ylab, main, border = "gray62",
146+
gdalraster::plot_geom(fia_poly, xlab, ylab, main, border = subp_border_col,
143147
lwd = subp_border_lwd, bbox = rct)
144148

145149
for (i in seq_len(nrow(trees_in))) {
@@ -151,9 +155,9 @@ plot_crowns <- function(tree_list, subplot = NULL, microplot = FALSE,
151155
}
152156
}
153157

154-
border_col <- grDevices::adjustcolor("gray62", alpha.f = 0.2)
155-
gdalraster::plot_geom(fia_poly, border = border_col, lwd = subp_border_lwd,
156-
add = TRUE)
158+
border_col_adj <- grDevices::adjustcolor(subp_border_col, alpha.f = 0.2)
159+
gdalraster::plot_geom(fia_poly, border = border_col_adj,
160+
lwd = subp_border_lwd, add = TRUE)
157161

158162
invisible(tree_list)
159163
}

man/plot_crowns.Rd

Lines changed: 10 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)