diff --git a/R/plot.R b/R/plot.R index 47fec471a77..0836cbd0cf3 100644 --- a/R/plot.R +++ b/R/plot.R @@ -57,6 +57,10 @@ #' the marked vertex groups. It is in the same units as the vertex sizes. If a #' vector is given, then different values are used for the different vertex #' groups. +#' @param mark.lwd A numeric scalar or vector, the linewidth of the border around +#' the marked vertex groups. If a +#' vector is given, then different values are used for the different vertex +#' groups. #' @param loop.size A numeric scalar that allows the user to scale the loop edges #' of the network. The default loop size is 1. Larger values will produce larger #' loops. @@ -92,6 +96,7 @@ plot.igraph <- function( mark.col = rainbow(length(mark.groups), alpha = 0.3), mark.border = rainbow(length(mark.groups), alpha = 1), mark.expand = 15, + mark.lwd = 1, loop.size = 1, ... ) { @@ -252,6 +257,7 @@ plot.igraph <- function( mark.border <- rep(mark.border, length.out = length(mark.groups)) mark.col <- rep(mark.col, length.out = length(mark.groups)) mark.expand <- rep(mark.expand, length.out = length(mark.groups)) + mark.lwd <- rep(mark.lwd, length.out = length(mark.groups)) for (g in seq_along(mark.groups)) { .members <- mark.groups[[g]] @@ -267,7 +273,8 @@ plot.igraph <- function( expand.by = mark.expand[g] / 200, shape = mark.shape[g], col = mark.col[g], - border = mark.border[g] + border = mark.border[g], + border.lwd = mark.lwd[g] ) } @@ -1776,7 +1783,8 @@ igraph.polygon <- function( expand.by = 15 / 200, shape = 1 / 2, col = "#ff000033", - border = NA + border = NA, + border.lwd = 1 ) { by <- expand.by pp <- rbind( @@ -1788,5 +1796,13 @@ igraph.polygon <- function( ) cl <- convex_hull(pp) - xspline(cl$rescoords, shape = shape, open = FALSE, col = col, border = border) + + xspline( + cl$rescoords, + shape = shape, + open = FALSE, + col = col, + border = border, + lwd = border.lwd + ) } diff --git a/man/plot.igraph.Rd b/man/plot.igraph.Rd index 36451e890b8..c1ee1232a98 100644 --- a/man/plot.igraph.Rd +++ b/man/plot.igraph.Rd @@ -16,6 +16,7 @@ mark.col = rainbow(length(mark.groups), alpha = 0.3), mark.border = rainbow(length(mark.groups), alpha = 1), mark.expand = 15, + mark.lwd = 1, loop.size = 1, ... ) @@ -58,6 +59,11 @@ the marked vertex groups. It is in the same units as the vertex sizes. If a vector is given, then different values are used for the different vertex groups.} +\item{mark.lwd}{A numeric scalar or vector, the linewidth of the border around +the marked vertex groups. If a +vector is given, then different values are used for the different vertex +groups.} + \item{loop.size}{A numeric scalar that allows the user to scale the loop edges of the network. The default loop size is 1. Larger values will produce larger loops.} diff --git a/tests/testthat/_snaps/plot/mark-border-lwd.svg b/tests/testthat/_snaps/plot/mark-border-lwd.svg new file mode 100644 index 00000000000..2bf2b3a917d --- /dev/null +++ b/tests/testthat/_snaps/plot/mark-border-lwd.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/test-plot.R b/tests/testthat/test-plot.R index 171f6bb7568..106bdeb0546 100644 --- a/tests/testthat/test-plot.R +++ b/tests/testthat/test-plot.R @@ -154,3 +154,26 @@ test_that("Arrow drawing works correctly", { } vdiffr::expect_doppelganger("standard-arrow-sizes", standard_arrow_sizes) }) + +test_that("mark border linewidth", { + skip_if_not_installed("vdiffr") + mark_border_lwd <- function() { + g <- make_full_graph(4, directed = FALSE) + V(g)$x <- c(1, 2, 2, 1) + V(g)$y <- c(1, 1, 2, 2) + wc <- cluster_walktrap(g) + plot( + wc, + g, + vertex.label = NA, + vertex.size = 20, + mark.shape = 0, + edge.width = 0.1, + mark.expand = 40, + mark.lwd = 5, + margin = 1 + ) + } + + vdiffr::expect_doppelganger("mark-border-lwd", mark_border_lwd) +})