igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Problems with Transparency Plotting


From: Gábor Csárdi
Subject: Re: [igraph] Problems with Transparency Plotting
Date: Wed, 14 Oct 2009 14:51:39 +0200

On Wed, Oct 14, 2009 at 2:34 PM, Lorenzo Isella
<address@hidden> wrote:
> Dear All,
> I am trying to repeat the steps of the example about transparency plotting
> for the R bindings of igraph
>
> http://igraph.sourceforge.net/screenshots2.html#3
>
> Consider a graph whose edgelist is given at the bottom of this email and
> that is saved into the file edgelist-graph_no-weight49_.dat.
> Then consider the snippet:
>
> rm(list=ls())
> library(igraph)
> library(Cairo)
>
> fn <- paste("edgelist-graph_no-weight49_.dat")
> g <- read.graph(fn, "edgelist")
> g <- as.undirected(g)
> d <- get.diameter(g)
>
>
> pdf("transparency_and_diameter.pdf")

Btw., 'pdf' is not a 'Cairo' device, that would be 'CairoPDF'. If your
R supports Cairo, then it does not matter, but transparency might not
work with ordinary 'Xlib' graphics, and then you would need to use
'CairoPDF'.

> l <- layout.fruchterman.reingold(g)
> l <- layout.norm(l, -1,1, -1,1)
> l2 <- l[ d, ]

This should be

l2 <- l[d+1,]

Again, the 0-1 catch.

> plot(g, layout=l,
>    vertex.label.dist=0.5,   vertex.color="#ff000033",
>    vertex.frame.color="#ff000033", edge.color="#55555533",vertex.label=NA,
> vertex.size=4)
>
> plot(subgraph(g,d),layout=l2,
> vertex.color="#ff0000", vertex.frame.color="#ff0000",
> edge.color="#555555",vertex.label=NA, vertex.size=4,
>    add=TRUE, rescale=FALSE)

Another trap is here, you cannot be sure that the lines in 'l2'
correspond to the proper vertices in the subgraph. In this case they
don't. You need to use vertex attributes to do this:

V(g)$id <- seq(vcount(g))-1
g2 <- subgraph(g, d)
plot(g2, layout=l[ V(g2)$id+1, ],
vertex.color="#ff0000", vertex.frame.color="#ff0000",
   edge.color="#555555",vertex.label=NA, vertex.size=4,
   add=TRUE, rescale=FALSE)

(We did not even use 'l2' here, so it is not needed.)

I hope this helps.

Best,
Gabor

> dev.off()
>
> My problem is that the diameter d is
>> d
> [1]  1  0 11 10
>
> but in the resulting transparency plot I see only 3 nodes and one edge.
> Obviously something went wrong, but can anyone tell me exactly where?
> Many thanks
>
> Lorenzo
>
>
>
>
> 0 1
> 0 2
> 0 3
> 0 4
> 0 5
> 0 6
> 0 7
> 0 8
> 0 11
> 0 12
> 1 2
> 1 3
> 1 4
> 1 5
> 1 6
> 1 7
> 1 8
> 1 9
> 1 12
> 2 3
> 2 4
> 2 5
> 2 6
> 2 7
> 2 8
> 2 9
> 2 11
> 2 12
> 3 4
> 3 5
> 3 6
> 3 7
> 3 12
> 4 5
> 4 6
> 4 7
> 4 12
> 5 6
> 5 7
> 5 8
> 5 9
> 5 12
> 6 7
> 6 8
> 6 9
> 6 12
> 7 12
> 8 9
> 9 11
> 10 11
>
>
>
>
>
>
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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