Open cisGrammar opened 5 months ago
Not sure if a bug or a feature but the coloring depends on the alpha (or edge_alpha) aesthetic being set:
ggraph(highschool) +
geom_edge_bundle_force(aes(color=as.factor(year), alpha = 0))
That is for sure a bug
library(ggraph)
#> Loading required package: ggplot2
ggraph(highschool,"stress") +
geom_edge_bundle_force(aes(color=as.factor(year), alpha = 0))
ggraph(highschool, "stress") +
geom_edge_bundle_force(aes(color = as.factor(year)))
Created on 2024-07-09 with reprex v2.1.0
This code can not add color aes
library(ggraph) packageVersion("ggraph")
[1] ‘2.2.1’
ggraph(highschool) + geom_edge_bundle_force(aes(color=as.factor(year)) )
sessionInfo() R version 4.0.1 (2020-06-06) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS High Sierra 10.13.6
Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.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] stats graphics grDevices datasets utils methods base
other attached packages: [1] ggraph_2.2.1 ggplot2_3.5.1 colorout_1.2-2
loaded via a namespace (and not attached): [1] Rcpp_1.0.12 pillar_1.9.0 compiler_4.0.1 viridis_0.6.2 [5] tools_4.0.1 viridisLite_0.4.1 memoise_2.0.1 lifecycle_1.0.3 [9] tibble_3.2.1 gtable_0.3.5 pkgconfig_2.0.3 rlang_1.1.0 [13] tidygraph_1.2.1 igraph_1.3.0 cli_3.6.0 ggrepel_0.9.5 [17] fastmap_1.1.0 gridExtra_2.3 withr_2.5.0 dplyr_1.1.4 [21] generics_0.1.3 vctrs_0.6.5 graphlayouts_1.1.1 grid_4.0.1 [25] tidyselect_1.2.0 glue_1.6.2 R6_2.5.1 fansi_1.0.3 [29] polyclip_1.10-0 tidyr_1.3.0 purrr_1.0.1 tweenr_2.0.2 [33] farver_2.1.1 magrittr_2.0.3 scales_1.3.0 MASS_7.3-58.1 [37] ggforce_0.4.2 colorspace_2.0-3 utf8_1.2.2 munsell_0.5.0 [41] cachem_1.0.6
The bug is here in StatEdgeBundleForce0$compute_panel function you should return " cbind(edges, data[edges$group, !names(data) %in% c("x", "y", "xend", "yend", "PANEL", "group"), drop = FALSE]) "