Skip to content

glitch with *_cap = label_rect(node*.name) #84

Description

@maxheld83

We're loving the package and all the fantastic options.

We ran into a bit of a glitch with using the (very appealing) start_cap = label_rect(node1.name) etc. aesthetics in our example; some of the edges just completely freak out and go to 0,0 in the plot.

We couldn't reproduce this with any of the default datasets, so – unfortunately – we have to bother you with our own reprex.

library(ggraph)
library(igraph)

graphlong <- structure(list(categories = c("A", "A", "A", "B", "B", "B", "B",
                                           "C", "C", "C", "C", "C", "C", "C", "C", "C", "D", "D", "D", "D",
                                           "E", "E", "E", "E", "F", "F", "F", "F", "F", "F", "F", "F", "F",
                                           "F", "G", "G", "G", "G", "H", "H", "H", "H", "H", "H", "H", "H",
                                           "H", "H", "H", "I", "I", "K", "K", "K", "K", "K"), items = c("immer_dasselbe",
                                                                                                        "karawane", "krokodil", "widerstand", "bienensprachen", "immer_dasselbe",
                                                                                                        "morgen", "boeses_huhn", "boeses_huhn", "boeses_huhn", "laender",
                                                                                                        "laender", "laender", "nuschel", "nuschel", "nuschel", "graue_haare",
                                                                                                        "kopf_verdrehen", "unnuetzes_gedicht", "zeitwortmelodie", "nachtlied",
                                                                                                        "unnuetzes_gedicht", "wende", "zeitwortmelodie", "ausserirdischer_besuch",
                                                                                                        "kopf_verdrehen", "je_desto", "kakadu", "komma", "tiere_fressen",
                                                                                                        "marktkram", "opa_essen", "stoerung", "aus_dem_lexikon", "kakadu",
                                                                                                        "stoerung", "aber_wie", "ich_wir", "unterschied", "erfindungen",
                                                                                                        "karawane", "krokodil", "muecke_elefant", "schuld", "unnuetzes_gedicht",
                                                                                                        "vergleichsweise", "widerstand", "zeitwortmelodie", "zensiert",
                                                                                                        "komma", "opa_essen", "ausserirdischer_besuch", "boeses_huhn",
                                                                                                        "krokodil", "muecke_elefant", "osterhase"), Subcode = structure(c(5L,
                                                                                                                                                                          5L, 5L, 3L, 3L, 3L, 3L, 3L, 1L, 13L, 3L, 1L, 13L, 3L, 1L, 13L,
                                                                                                                                                                          1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 13L, 13L, 13L, 13L, 13L, 13L,
                                                                                                                                                                          13L, 13L, 13L, 13L, NA, NA, NA, NA, 12L, 12L, 12L, 12L, 12L,
                                                                                                                                                                          12L, 12L, 12L, 12L, 12L, 12L, 2L, 2L, 5L, 5L, 5L, 5L, 5L), .Label = c("Genre",
                                                                                                                                                                                                                                                "sprachlich", "textuell", "kommunikativ", "medial", "Handlung_Zustand",
                                                                                                                                                                                                                                                "Zeit", "Objekt", "Figur", "Ort", "metakognitiv", "epistemisch",
                                                                                                                                                                                                                                                "affektiv", "intertextuell", "generativ", "Primär_leserseitig"
                                                                                                                                                                          ), class = "factor"), Supercode = c("Sprache", "Sprache", "Sprache",
                                                                                                                                                                                                              "Sprache", "Sprache", "Sprache", "Sprache", "Sprache", "Sprache",
                                                                                                                                                                                                              "Modalität", "Sprache", "Sprache", "Modalität", "Sprache",
                                                                                                                                                                                                              "Sprache", "Modalität", "Sprache", "Sprache", "Sprache", "Sprache",
                                                                                                                                                                                                              "Sprache", "Sprache", "Sprache", "Sprache", "Modalität", "Modalität",
                                                                                                                                                                                                              "Modalität", "Modalität", "Modalität", "Modalität", "Modalität",
                                                                                                                                                                                                              "Modalität", "Modalität", "Modalität", NA, NA, NA, NA, "Modalität",
                                                                                                                                                                                                              "Modalität", "Modalität", "Modalität", "Modalität", "Modalität",
                                                                                                                                                                                                              "Modalität", "Modalität", "Modalität", "Modalität", "Modalität",
                                                                                                                                                                                                              "Sprache", "Sprache", "Sprache", "Sprache", "Sprache", "Sprache",
                                                                                                                                                                                                              "Sprache")), .Names = c("categories", "items", "Subcode", "Supercode"
                                                                                                                                                                                                              ), row.names = c(NA, 56L), class = "data.frame")

glon_graph <- igraph::graph_from_data_frame(d = graphlong, directed = FALSE)

g <- ggraph(graph = glon_graph, layout = "bipartite", types = igraph::bipartite_mapping(graph = glon_graph)$type)
g <- g + geom_edge_fan(mapping = aes(start_cap = label_rect(node1.name), end_cap = label_rect(node2.name)))
g <- g + geom_node_label(aes(label = name), repel = FALSE, hjust = "inward")
g <- g + coord_flip()
plot(g)

glitchyedges


sessionInfo() gives:

R version 3.4.1 (2017-06-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/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 utils     datasets  methods   base     

other attached packages:
[1] bindrcpp_0.2        igraph_1.1.2        magrittr_1.5        ggraph_1.0.0       
[5] ggplot2_2.2.1       checkmate_1.8.3     pensieve_0.0.0.9019

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.12      cellranger_1.1.0  compiler_3.4.1    plyr_1.8.4        bindr_0.1        
 [6] viridis_0.4.0     tools_3.4.1       testthat_1.0.2    digest_0.6.12     lettercase_0.13.1
[11] evaluate_0.10.1   tibble_1.3.4      gtable_0.2.0      viridisLite_0.2.0 pkgconfig_2.0.1  
[16] rlang_0.1.2.9000  yaml_2.1.14       ggrepel_0.6.5     gridExtra_2.2.1   stringr_1.2.0    
[21] dplyr_0.7.2       knitr_1.17        hms_0.3           rprojroot_1.2     grid_3.4.1       
[26] glue_1.1.1        R6_2.2.2          readxl_1.0.0      bookdown_0.5      rmarkdown_1.6    
[31] reshape2_1.4.2    readr_1.1.1       tweenr_0.1.5      udunits2_0.13     backports_1.1.0  
[36] scales_0.5.0      htmltools_0.3.6   MASS_7.3-47       units_0.4-6       assertthat_0.2.0 
[41] ggforce_0.1.1     colorspace_1.3-2  labeling_0.3      stringi_1.1.5     lazyeval_0.2.0   
[46] munsell_0.4.3     crayon_1.3.2     

cc @verenakasztantowicz

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions