igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[igraph] Plotting geo networks with igraph > 0.7.1


From: Marco T. Bastos
Subject: [igraph] Plotting geo networks with igraph > 0.7.1
Date: Thu, 19 Dec 2019 14:06:10 -0000

Hi guys,

I searched the list but couldn't find an answer to my problem. I noticed
this issue long ago, but I have managed to work around the problem by using
igraph 0.7.1 along with more recent releases.

I can plot network graphs over a geographic grid with igraph 0.7.1 without
any issues. Unfortunately that isn't possible with newer versions, which
invariably place the vertices somewhere else. 

I looked into the new parameters for plotting in igraph > 0.7.1, which are
many, but I couldn't figure out if this was a bug or if the function
layout.norm() now requires some extra parameters.

The code below reproduces the error. It plots a network over a map
flawlessly with igraph 0.7.1, but subsequent versions fail to place the
vertices in their correct location. Am I missing something important here?

Thanks,
Marco

# create graph
library(igraph)
vertex.df <- data.frame(vertex=c("messina_hof", "kevinkennethlau",
"prosperitygal", "gotexan"),
                        latitude=c(30.31602, 29.43314, 29.76045, 30.26759),
                        longitude=c(-98.96895, -95.14341, -95.36978,
-97.74299),
                        stringsAsFactors=F)
edges.df <- data.frame(V1=c("messina_hof", "prosperitygal"), 
                       V2=c("gotexan", "kevinkennethlau"),
                       stringsAsFactors=F)
texas.g <- graph.data.frame(edges.df, directed=T, vertices=vertex.df)

# plot base map
library(maps)
map("state", region="Texas")

# plot network overlay
plot.igraph(texas.g,
            layout=
layout.norm(as.matrix(data.frame(lon=as.numeric(V(texas.g)$longitude),lat=as
.numeric(V(texas.g)$latitude)))), 
            xlim = c(min(as.numeric(V(texas.g)$longitude)),
max(as.numeric(V(texas.g)$longitude))), 
            ylim = c(min(as.numeric(V(texas.g)$latitude)),
max(as.numeric(V(texas.g)$latitude))), 
            edge.curved = TRUE,
            rescale = FALSE,
            add=T)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]