Skip to content

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

@nathancday

Description

@nathancday

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions