Skip to content

Problem with end_cap when combined with weighted edges #62

@balthasarbickel

Description

@balthasarbickel

Consider the following MWE:
m <- matrix(c(1/4,2/4,1/4, 1/5,1/5,3/5, 3/6,1/6,2/6), ncol=3, byrow=T)
gg <- graph_from_adjacency_matrix(adjmatrix=m, weighted=TRUE, mode="directed", diag=T)

When using end_cap, as in the following, the edge widths are wrong:

ggraph(gg, layout = 'linear', circular=T) + 
	geom_edge_fan(aes(width=weight, label=round(weight,2)), 
		                   end_cap = circle(.5, 'cm'),
			           angle_calc='along', label_dodge=unit(-0.3, "cm")) + 	
	geom_edge_loop(aes(width=weight, direction=rep(c(30,270,150),3), label=round(weight,2)),
				    end_cap = circle(.5, 'cm'),
				    angle_calc='along', label_dodge=unit(-0.3, "cm")) +
		geom_node_point(size=12)

The edge widths are correct again if we remove the end_cap spec:

ggraph(gg, layout = 'linear', circular=T) + 
	geom_edge_fan(aes(width=weight, label=round(weight,2)), 
		                 #end_cap = circle(.5, 'cm'),
				   angle_calc='along', label_dodge=unit(-0.3, "cm")) + 	
	geom_edge_loop(aes(width=weight, direction=rep(c(30,270,150),3), label=round(weight,2)),
				 #end_cap = circle(.5, 'cm'),
				   angle_calc='along', label_dodge=unit(-0.3, "cm")) +
	geom_node_point(size=12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions