briatte / ggnet

Network visualization with ggplot2
https://briatte.github.io/ggnet/
194 stars 33 forks source link

Use approach in NetworkX for arrows #24

Closed aterhorst closed 5 years ago

aterhorst commented 7 years ago

Hi. The arrow gap workaround is not working for me. I have different node sizes so a standard arrow gap is not helpful.

I was wondering if ggnet could not implement something similar to what is used in NetworkX? This is a python package for network analysis. Essentially this uses a line stub instead of an arrow. The aesthetics can be made to look nice like the examples in http://cxhernandez.com/tutorials/networks/2015/03/29/shortest-path.html

briatte commented 7 years ago

Thanks for the suggestion, @aterhorst -- I am familiar with NetworkX but was not familiar with the examples you link to.

You can already implement the trick used in the example by having two edges on top of one another (that trick is easier to implement with ggnetwork. However, the problem would remain that the stubs would be of different length depending on node size.

Unless I find a way to measure actual instead of relative node size, I am stuck, for now, with the current behaviour of ggnet. It's on my top-3 list of improvements.

aterhorst commented 7 years ago

Thanks. What they do is measure stub length as proportion of edge length e.g. 1:10. So longer edges have longer stubs. I think it is conditioned on node size as well.

Andrew Terhorst Open Innovation Researcher Location leader for Sandy Bay site

DATA61 | CSIRO E andrew.terhorst@csiro.au T +61 3 6237 5662 M +61 400 869 594 15 College Rd, Sandy Bay, TAS 7005 http://www.data61.csiro.au http://people.csiro.au/T/A/Andrew-Terhorst.aspx


From: François Briatte notifications@github.com Sent: Tuesday, 20 September 2016 2:15 PM To: briatte/ggnet Cc: Terhorst, Andrew (Data61, Sandy Bay); Mention Subject: Re: [briatte/ggnet] Use approach in NetworkX for arrows (#24)

Thanks for the suggestion, @aterhorsthttps://github.com/aterhorst -- I am familiar with NetworkX but was not familiar with the examples you link to.

You can already implement the trick used in the example by having two edges on top of one another (that trick is easier tom implement with ggnetwork. However, the problem would remain that the stubs would be of different length depending on node size.

Unless I find a way to measure actual instead of relative node size, I am stuck, for now, with the current behaviour of ggnet.

You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/briatte/ggnet/issues/24#issuecomment-248197172, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHBsi2G-TmGkqzTPzH2i_cnS7jvYIXK7ks5qr13zgaJpZM4J_0ik.

briatte commented 7 years ago

I haven't looked into grid long enough to find out how big the points are in the corresponding geom—but I know it's pretty complex to sort out… which is why this improvement is not yet there.

I'm going to ask @hadley in case there is a simple answer:

Dear Hadley, if I draw a geom_segment that ends at (xend, yend) and there is another geom_point drawn there at a given size, is there an easy way to stop drawing the segment just before it intersects with the point?

hadley commented 7 years ago

Not that I know of

briatte commented 5 years ago

Closing this, as I won't revisit the code to solve the 'arrow gap' issue better than it is.

As mentioned above, ggnetwork should give slightly better results on that issue, but the best solution is almost certainly to use ggraph.

Thanks to Andrew and Hadley for their contributions.