diff --git a/DESCRIPTION b/DESCRIPTION index 803b41f5..253d664a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,7 +48,8 @@ Suggests: deldir, gganimate, covr, - sf + sf, + sfnetworks LinkingTo: Rcpp RoxygenNote: 7.3.1 Depends: diff --git a/NAMESPACE b/NAMESPACE index d9f53144..e8397916 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -393,6 +393,7 @@ importFrom(igraph,simplify) importFrom(igraph,unfold_tree) importFrom(igraph,vertex_attr) importFrom(lifecycle,deprecated) +importFrom(memoise,memoise) importFrom(rlang,.data) importFrom(rlang,as_quosure) importFrom(rlang,enquo) diff --git a/NEWS.md b/NEWS.md index 83d4ec9b..08dfe755 100644 --- a/NEWS.md +++ b/NEWS.md @@ -31,7 +31,8 @@ `geom_edge_bundle_minimal()` (+ variants) to provide support for edge bundling (#267) * Add "metro" layout from graphlayouts for metroline like layouts -* Add `layout_sf()`, `geom_node_sf()` and `geom_edge_sf()` to support plotting of [`sfnetwork`](https://luukvdmeer.github.io/sfnetworks/) objects (#275) +* Add `layout_sf()`, `geom_node_sf()` and `geom_edge_sf()` to support plotting of + [`sfnetwork`](https://luukvdmeer.github.io/sfnetworks/) objects (#275) # ggraph 2.1.0 diff --git a/R/geom_edge_bundle_force.R b/R/geom_edge_bundle_force.R index 99ef7578..e3b2c427 100644 --- a/R/geom_edge_bundle_force.R +++ b/R/geom_edge_bundle_force.R @@ -301,4 +301,4 @@ force_bundle <- function(data, K, C, P, S, P_rate, I, I_rate, compatibility_thre ) } -force_bundle_mem <- memoise::memoise(force_bundle) +force_bundle_mem <- memoise(force_bundle) diff --git a/R/geom_edge_bundle_minimal.R b/R/geom_edge_bundle_minimal.R index c4b820b6..53f0428e 100644 --- a/R/geom_edge_bundle_minimal.R +++ b/R/geom_edge_bundle_minimal.R @@ -274,4 +274,4 @@ minimal_bundle <- function(graph, nodes, from, to, max_distortion = 2, weight_fa data_frame0(x = nodes$x[paths], y = nodes$y[paths], group = ids) } -minimal_bundle_mem <- memoise::memoise(minimal_bundle) +minimal_bundle_mem <- memoise(minimal_bundle) diff --git a/R/geom_edge_bundle_path.R b/R/geom_edge_bundle_path.R index 1bf2b30f..9714f4a2 100644 --- a/R/geom_edge_bundle_path.R +++ b/R/geom_edge_bundle_path.R @@ -325,4 +325,4 @@ path_bundle <- function(graph, nodes, from, to, directed = directed, max_distort data_frame0(x = nodes$x[paths], y = nodes$y[paths], group = ids) } -path_bundle_mem <- memoise::memoise(path_bundle) +path_bundle_mem <- memoise(path_bundle) diff --git a/R/geom_node_sf.R b/R/geom_node_sf.R index 50f7d92e..92a32986 100644 --- a/R/geom_node_sf.R +++ b/R/geom_node_sf.R @@ -24,10 +24,12 @@ #' @family geom_node_* #' #' @examples +#' library(tidygraph) +#' #' if (require("sfnetworks", quietly = TRUE)) { -#' gr <- sfnetworks::as_sfnetwork(roxel) %>% -#' mutate(centrality = centrality_betweenness()) -#' ggraph(gr, 'sf') + geom_node_sf(aes(color = centrality)) +#' gr <- sfnetworks::as_sfnetwork(roxel) +#' ggraph(gr, 'sf') + +#' geom_node_sf(aes(color = centrality_betweenness())) #' } #' #' @export diff --git a/R/ggraph-package.R b/R/ggraph-package.R index 900d57f0..cfb6c680 100644 --- a/R/ggraph-package.R +++ b/R/ggraph-package.R @@ -1,4 +1,3 @@ -#' @aliases ggraph-package #' @keywords internal '_PACKAGE' @@ -6,6 +5,7 @@ # roxygen namespace tags. Modify with care! ## usethis namespace: start #' @import ggplot2 tidygraph rlang vctrs +#' @importFrom memoise memoise #' @importFrom lifecycle deprecated #' @importFrom Rcpp sourceCpp #' @useDynLib ggraph diff --git a/R/layout_stress.R b/R/layout_stress.R index 59d2f9e4..b67597d8 100644 --- a/R/layout_stress.R +++ b/R/layout_stress.R @@ -59,7 +59,7 @@ layout_tbl_graph_stress <- function(graph, weights = NULL, niter = 500, xy <- cbind(x_coord, y_coord) if (anyNA(xy)) { xy <- layout_with_fixed_coords(graph, xy, weights = weights, iter = niter, - tol = tol, mds = mds, bbox = bbox) + tol = tolerance, mds = mds, bbox = bbox) } } else { dim <- if (is.null(x_coord)) "y" else "x" diff --git a/man/geom_node_sf.Rd b/man/geom_node_sf.Rd index 3aa8dc06..a5073779 100644 --- a/man/geom_node_sf.Rd +++ b/man/geom_node_sf.Rd @@ -67,10 +67,12 @@ different shapes, colours and sizes. } \examples{ +library(tidygraph) + if (require("sfnetworks", quietly = TRUE)) { - gr <- sfnetworks::as_sfnetwork(roxel) \%>\% - mutate(centrality = centrality_betweenness()) - ggraph(gr, 'sf') + geom_node_sf(aes(color = centrality)) + gr <- sfnetworks::as_sfnetwork(roxel) + ggraph(gr, 'sf') + + geom_node_sf(aes(color = centrality_betweenness())) } }