Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra edges drawn when using label_rect() with tree layout #70

Closed
nathancday opened this issue Apr 20, 2017 · 1 comment
Closed

Extra edges drawn when using label_rect() with tree layout #70

nathancday opened this issue Apr 20, 2017 · 1 comment

Comments

@nathancday
Copy link

I can only create this problem when using layout = "tree" and start_cap = label_rect(). Any other start/end cap geoms work fine and any other layout works fine too. But when both conditions are met, extra edges are drawn from a (random?) subset of nodes to the bottom left corner (-1,0) of the plot.

library(igraph)
library(ggraph)

#small data
simple <- make_graph('bull')
V(simple)$name <- c('Thomas', 'Bob', 'Hadley', 'Winston', 'Baptiste')
E(simple)$type <- sample(c('friend', 'foe'), 5, TRUE)

# bad graph with the phantom extra edges
ggraph(simple, layout = 'tree') + 
    geom_edge_link(aes(start_cap = label_rect(node1.name),
                       end_cap = label_rect(node2.name)), 
                   arrow = arrow(length = unit(4, 'mm'))) + 
    geom_node_text(aes(label = name))

image

@rexdouglass
Copy link

rexdouglass commented Jan 14, 2018

I'm getting the same problem with any layout. I'm showing two behaviors (1) Some edges don't get drawn at all. (2) Some edges get drawn to the bottom left corner. Resizing the plot window by hand through the operating system will sometimes shift which edges demonstrate the problem. That suggests it's something to do with the automatic layout code, giving it a little more room can sometimes solve it.

p <- ggraph(g1, layout = 'auto') +
geom_edge_link(aes(start_cap = label_rect(node1.name),
end_cap = label_rect(node2.name)),
arrow = arrow(length = unit(1, 'mm'))) +
geom_node_text(aes(label = name), size=2)
p

Using nicely as default layout
image

sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] NamedEntities_0.0.0.9000 data.table_1.10.4-3 bindrcpp_0.2 ggraph_1.0.0.9999 ggplot2_2.2.1.9000 igraph_1.1.2

loaded via a namespace (and not attached):
[1] nlme_3.1-131 sf_0.6-0 lubridate_1.7.1 devtools_1.13.4 RColorBrewer_1.1-2 httr_1.3.1 rprojroot_1.3-2 data.tree_0.7.4 backports_1.1.2 tools_3.4.3
[11] R6_2.2.2 rgeos_0.3-26 DBI_0.7 lazyeval_0.2.1 colorspace_1.3-2 sp_1.2-6 withr_2.1.1.9000 gridExtra_2.3 mnormt_1.5-5 curl_3.1
[21] compiler_3.4.3 git2r_0.21.0 rvest_0.3.2 xml2_1.1.1 influenceR_0.1.0 labeling_0.3 scales_0.5.0.9000 classInt_0.1-24 psych_1.7.8 readr_1.1.1
[31] timelineS_0.1.1 callr_1.0.0 commonmark_1.4 stringr_1.2.0 digest_0.6.14 foreign_0.8-69 rmarkdown_1.8 googlesheets_0.2.2 pkgconfig_2.0.1 htmltools_0.3.6
[41] htmlwidgets_0.9 rlang_0.1.6.9003 readxl_1.0.0 rstudioapi_0.7 bindr_0.1 visNetwork_2.0.3 jsonlite_1.5 dplyr_0.7.4 rgexf_0.15.3 magrittr_1.5
[51] kableExtra_0.6.1 Rcpp_0.12.14 munsell_0.4.3 viridis_0.4.1 stringi_1.1.6 yaml_2.1.16 MASS_7.3-48 plyr_1.8.4 grid_3.4.3 parallel_3.4.3
[61] ggrepel_0.7.0 forcats_0.2.0 udunits2_0.13 lattice_0.20-35 haven_1.1.0 hms_0.4.0 knitr_1.18 pillar_1.0.1 reshape2_1.4.3 WikidataR_1.4.0
[71] XML_3.98-1.9 glue_1.2.0 evaluate_0.10.1 downloader_0.4 modelr_0.1.1 tweenr_0.1.5 testthat_2.0.0 cellranger_1.1.0 openssl_0.9.9 WikipediR_1.5.0
[81] gtable_0.2.0 collapsibleTree_0.1.6 purrr_0.2.4 tidyr_0.7.2 assertthat_0.2.0 ggforce_0.1.1 janitor_0.3.1 broom_0.4.3 tidygraph_1.0.0.9999 tidyverse_1.2.1
[91] rnaturalearth_0.1.0 e1071_1.6-8 roxygen2_6.0.1 class_7.3-14 viridisLite_0.2.0 tibble_1.4.1 memoise_1.1.0 units_0.5-1 Rook_1.1-1 DiagrammeR_0.9.2
[101] brew_1.0-6 here_0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants