igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Maps and Networks


From: Gábor Csárdi
Subject: Re: [igraph] Maps and Networks
Date: Fri, 29 Apr 2011 10:55:43 -0400

Lorenzo,

see the 'add', 'rescale' arguments to plot.igraph() and
?igraph.plotting and ?plot.igraph. The idea is:

plot(g, add=TRUE, rescale=FALSE, layout=coords)

and you need to set up 'coords' to match the coordinates on your map plot.

G.

On Fri, Apr 29, 2011 at 10:48 AM, Lorenzo Isella
<address@hidden> wrote:
> Hi Gary,
> And thanks a lot for your suggestion.
> This is half a way through what I have in mind: I can put points (and
> probably lines) on a map by specifying their latitude and longitude.
> However, I wonder if I can also use "plot" from the igraph to generate a
> network (where the node layout is given in terms of longitude and latitude)
> to overlay on top of the map.
> For instance, consider the snippet at the end of the email.
> In the first generated pdf, I can actually plot some points on the map of
> Italy, but when I try to do the same using the igraph library, I fail to
> overlay the two plots.
> Any suggestion here is really appreciated.
> Cheers
>
> Lorenzo
>
>
>
> rm(list=ls())
>
> library(igraph)
> library(maps)
>
>
> t <- map("italy", plot=FALSE)
>
>
> pos1 <- c(16,40.3)
> pos2 <- c(12,44)
> pos3 <- c(13,42)
>
> pdf("italy.pdf")
> plot(t$x, t$y, "l")
> points(pos1[1],pos1[2], bg="red", col="red", pch=21)
> points(pos2[1],pos2[2], bg="blue", col="blue", pch=21)
> points(pos3[1],pos3[2], bg="brown", col="brown", pch=21)
>
>
> dev.off()
>
>
>
> el <- matrix( c("foo", "bar", "bar", "foobar"), nc=2, byrow=TRUE)
> g <- graph.edgelist(el)
>
> g <- as.undirected(g)
>
> l <- matrix(ncol=2, nrow=3)
>
> l[1,] <- pos1
> l[2,] <- pos2
> l[3,] <- pos3
>
>
>
> pdf("italy2.pdf")
> plot(t$x, t$y, "l")
> plot(g, layout=l,
>     vertex.label.dist=0.5,vertex.label=NA, vertex.size=5)
>
>
> dev.off()
>
>
>
>
>
>
>
> On 27/04/11 18:11, Gary Weissman wrote:
>>
>> Hi Lorenzo,
>>
>> If I understand your question correctly, then you can use the maps library
>> in R.  There is a Stack Overflow thread which gives a little more detail
>> here:
>>
>> http://stackoverflow.com/questions/3951734/network-graph-and-us-map-in-r
>>
>> Best,
>> Gary
>>
>>
>>
>> On Apr 27, 2011, at 12:00 PM, address@hidden wrote:
>>
>>> Send igraph-help mailing list submissions to
>>>       address@hidden
>>>
>>> To subscribe or unsubscribe via the World Wide Web, visit
>>>        https://lists.nongnu.org/mailman/listinfo/igraph-help
>>> or, via email, send a message with subject or body 'help' to
>>>       address@hidden
>>>
>>> You can reach the person managing the list at
>>>       address@hidden
>>>
>>> When replying, please edit your Subject line so it is more specific
>>> than "Re: Contents of igraph-help digest..."
>>>
>>>
>>> Today's Topics:
>>>
>>>   1. Maps and Networks (Lorenzo Isella)
>>>
>>>
>>> ----------------------------------------------------------------------
>>>
>>> Message: 1
>>> Date: Wed, 27 Apr 2011 16:01:44 +0200
>>> From: Lorenzo Isella<address@hidden>
>>> To: address@hidden
>>> Subject: [igraph] Maps and Networks
>>> Message-ID:<address@hidden>
>>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>>
>>> Dear All,
>>> A question on the visualization side of network; from time to time we
>>> all happen to see geographical maps (e.g. air transportation) with a
>>> network overlaid upon them (e.g. links between London, Paris, Berlin and
>>> Rome, just to consider Europe only).
>>> I tend to use igraph under R and ggplot2 for statistical visualization,
>>> but how can one generate some good looking visualizations mainly by
>>> scripting only?
>>> As of now, I would not know even where I can fetch the maps (let's say
>>> Europe) for the task, let alone overlay a network upon them.
>>> Does anyone have experience with this kind of visualizations?
>>> A self-contained example even with fake data would help me a lot.
>>> Best Regards
>>>
>>> Lorenzo
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> _______________________________________________
>>> igraph-help mailing list
>>> address@hidden
>>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>>>
>>>
>>> End of igraph-help Digest, Vol 57, Issue 18
>>> *******************************************
>>
>> --
>> Gary Weissman
>> http://www.babelgraph.org/
>> address@hidden
>>
>>
>>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     MTA KFKI RMKI



reply via email to

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