briatte / ggnet

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

Plotting geonetworks #7

Closed ninjasoul closed 10 years ago

ninjasoul commented 10 years ago

I am not sure if an issue is the right way to ask this but I am trying to make a geographic network using ggplot2. I came across ggnet and it looks awesome. I saw that we need to provide as input the algorithm for laying out the graph to able to generate coordinates for nodes. But in case of a geographic network, I already have coordinates for my nodes. Is it possible to incorporate this information directly? Thanks.

briatte commented 10 years ago

I have added automatic detection of geographic coordinates in the network vertex attributes to the development version of ggnet. Run it from this address:

library(devtools)
source_url("https://github.com/briatte/ggnet/blob/master/ggnet.R")

Now just send a network with lat and lon vertex attributes to ggnet, and these will be used for node placement. Here's an example with French MPs:

Imgur

The feature is pending addition to the official branch. It's not perfect, though, because as the example shows, it cannot deal with overplotting (I don't know how to pass a jitter transformation to a plot with segments).