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)
Thanks for this - I'll look into it...
I'm also having the same issue as @balthasarbickel. I am having the problem with my own data and when using the minimal example provided above.
I have igraph_1.1.2 and ggraph_1.0.2. However, my loaded version of cappedPathGrob does not seem to match that in 401e175, which was supposed to fix the plotting problem (I used getAnywhere(cappedPathGrob)). When I tried to add the file cappedPath.R, modified by @thomasp85 to my Global environment to see if it would fix the plotting issue, I got this error: Error in setChildren(x, gList(lines)) :
can only set 'children' for a "gTree" .
Perhaps I did something wrong when I tried this method of adding the functions to my working environment. I am quite new.
@justjacqueline to get the dev version of a package on GitHub, you need to install it rather than loading a function in your global environment. Try devtools::install_github('thomasp85/ggraph')
. You'll need the devtools
package if you don't have it already (install.packages("devtools")
).
Most helpful comment
@justjacqueline to get the dev version of a package on GitHub, you need to install it rather than loading a function in your global environment. Try
devtools::install_github('thomasp85/ggraph')
. You'll need thedevtools
package if you don't have it already (install.packages("devtools")
).