igraph-help
[Top][All Lists]
Advanced

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

[igraph] Plotting subgraph over a semi-transparent graph


From: Sergio Jiménez
Subject: [igraph] Plotting subgraph over a semi-transparent graph
Date: Tue, 23 Sep 2008 18:12:52 +0200

I'm trying to plot, using igraph interface for Python, a subgraph over the
almost transparent original subgraph.
There is an example in R on
http://cneurocvs.rmki.kfki.hu/igraph/screenshots2.html#3

If I do the following: 

comm=g1.community_fastgreedy()
l1=comm[2]
g2=g1.subgraph(l1)

#Layout 
lyo=g1.layout("lgl")
lyo2=Layout([lyo[i] for i in l1])
fig = Plot(bbox=(lx,ly))
fig.add(g1, layout=lyo, opacity=0.2)
fig.add(g2, layout=lyo2)
fig.save("g1.png")


I obtain the subgraph centered and rescaled to fit the figure bounding box,
instead of over the vertex of the original layout.
To solve this problem I've played with the margin attribute of the
igraph.Plot method in the following way: 


comm=g1.community_fastgreedy()
l1=comm[2]
g2=g1.subgraph(l1)

#Layout 
lyo=g1.layout("lgl")
lyo2=Layout([lyo[i] for i in l1])
bb1=lyo.bounding_box()
bb2=lyo2.bounding_box()

x=bb1[2]-bb1[0]
y=bb1[3]-bb1[1]
lx=1024.0
ly=768.0
m1=(bb2[1]-bb1[1])*ly/y
m2=(bb2[0]-bb1[0])*lx/x
m3=(bb1[3]-bb2[3])*ly/y
m4=(bb1[2]-bb2[2])*lx/x

fig = Plot(bbox=(lx,ly))
fig.add(g1, layout=lyo, opacity=0.2)
fig.add(g2, layout=lyo2, opacity=1,margin=(m1,m2,m3,m4))
fig.save("g1.png")



But is there a smarter way to do this, using any option of layout or plot
classes?

Thanks

        Sergio


-----Mensaje original-----
De: address@hidden
[mailto:address@hidden En nombre de Lin
Freeman
Enviado el: martes, 23 de septiembre de 2008 16:12
Para: Help for igraph users
Asunto: Re: [igraph] beginner's help on igraph in R

As I said, I entered 'source("GUI.R")'.  Everything seemed okay.
Then, on the new window, I chose Graph > Create > By Hand.  That
opened the Data Editor window.  I entered a little data,
1 2
2 3
and closed the editor window.  That opened the Creating a graph by
hand window.  I clicked OK, and that showed the iGraph GUI window
containing 1 graph, called "New graph" containing 4 vertices and 2
edges where Dir. was set to NO. I clicked on the little box to the
left of that graph and clicked on Draw > Simple.That opened the "R
Graphics: Device 2 (ACTIVE)" window which remained blank.  And it also
locked the program and generated the error codes I reported earlier

Again, thanks for your help.

Best,
Lin

On Tue, Sep 23, 2008 at 6:38 AM, Csardi Gabor <address@hidden> wrote:
> Oh, ok, I know about this, of course. Could you please tell me
> what you did to make it crash? I'll need to be able to reproduce
> the crash.
>
> Best,
> Gabor Csardi
>
> On Tue, Sep 23, 2008 at 06:33:10AM -0700, Lin Freeman wrote:
>> Professor Csardi,
>>
>> Thank you for your answer.  GUI.R is a small gui found at
>> "http://geza.kzoo.edu/~csard/socnet.R.  It is a script that was
>> designed to help beginners like me to get started with igraph.  And it
>> works well in the windows version.  I have attached it here.
>>
>> Best,
>> Lin Freeman
>>
> [...]
>
> --
> Csardi Gabor <address@hidden>    MTA RMKI, ELTE TTK
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>



-- 
Linton C. Freeman
Institute for Mathematical Behavioral Sciences and
Department of Sociology
School of Social Sciences SSPA 2143
University of California
Irvine, CA 92697-5100

Office: (949) 824-6698
Home (CA): (949) 494-6139
 (FL): (941) 778-1074
Secretary: (949) 824-3663
FAX: (949) 824-3733


_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help
No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.169 / Virus Database: 270.6.21/1671 - Release Date: 23/09/2008
7:38





reply via email to

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