-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Description
According to #68, the correct way of using circular nodes and automatically setting the cap size to their radius is to use start_cap = circle(node1.size, unit = "native")
.
However, this approach does not work at the moment (edges are missing):
library(tidygraph)
library(ggraph)
set.seed(42)
create_notable('bull') %>%
mutate(name = c('Thomas', 'Bob', 'Hadley', 'Winston', 'Baptiste'), size = sample(10, 5)) %>%
ggraph(layout = 'graphopt') +
geom_edge_link(
aes(
start_cap = circle(node1.size, unit = "native"),
end_cap = circle(node2.size, unit = "native"),
),
arrow = arrow(length = unit(4, 'mm'))
) +
geom_node_circle(aes(r = size)) +
geom_node_text(aes(label = name)) +
coord_fixed()
This is because the node sizes are not scaled properly with unit = "native"
.
Using smaller, artificial values fixes the missing edge problem but no longer adapts to varying node sizes:
create_notable('bull') %>%
mutate(name = c('Thomas', 'Bob', 'Hadley', 'Winston', 'Baptiste'), size = sample(10, 5)) %>%
ggraph(layout = 'graphopt') +
geom_edge_link(
aes(
start_cap = circle(.1, unit = "native"),
end_cap = circle(.1, unit = "native"),
),
arrow = arrow(length = unit(4, 'mm'))
) +
geom_node_circle(aes(r = size)) +
geom_node_text(aes(label = name)) +
coord_fixed()
What would be the best way of dealing with this problem?
Session info
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin19.5.0 (64-bit)
Running under: macOS Catalina 10.15.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /usr/local/Cellar/openblas/0.3.10_1/lib/libopenblasp-r0.3.10.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggraph_2.0.3 ggplot2_3.3.2 tidygraph_1.2.0 graph_1.66.0 BiocGenerics_0.34.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 pillar_1.4.6 compiler_4.0.2 viridis_0.5.1 tools_4.0.2 digest_0.6.25
[7] viridisLite_0.3.0 lifecycle_0.2.0 tibble_3.0.3 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.7
[13] igraph_1.2.5 rstudioapi_0.11 ggrepel_0.8.2 gridExtra_2.3 withr_2.2.0 dplyr_1.0.1
[19] generics_0.0.2 vctrs_0.3.2 graphlayouts_0.7.0 stats4_4.0.2 grid_4.0.2 tidyselect_1.1.0
[25] glue_1.4.1 R6_2.4.1 polyclip_1.10-0 tidyr_1.1.1 purrr_0.3.4 tweenr_1.0.1
[31] farver_2.0.3 magrittr_1.5 scales_1.1.1 ellipsis_0.3.1 MASS_7.3-51.6 ggforce_0.3.2
[37] colorspace_1.4-1 labeling_0.3 munsell_0.5.0 crayon_1.3.4
Metadata
Metadata
Assignees
Labels
No labels