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

Problem with end_cap when combined with weighted edges #62

Closed
balthasarbickel opened this issue Feb 26, 2017 · 3 comments
Closed

Problem with end_cap when combined with weighted edges #62

balthasarbickel opened this issue Feb 26, 2017 · 3 comments

Comments

@balthasarbickel
Copy link

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)

@thomasp85
Copy link
Owner

Thanks for this - I'll look into it...

@justjacqueline
Copy link

justjacqueline commented Dec 19, 2018

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.

@malcolmbarrett
Copy link
Contributor

@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")).

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

4 participants