
From:  Christina Pikas 
Subject:  Re: [igraph] Graphing in a "polar" layout 
Date:  Thu, 5 Mar 2015 13:58:49 0500 
Date: Thu, 5 Mar 2015 12:18:11 +0100
From: Tamas Nepusz <address@hidden>
To: Help for igraph users <address@hidden>
Subject: Re: [igraph] Graphing in a "polar" layout
MessageID: <address@hidden>
ContentType: text/plain; charset=usascii
Hi Christina,
igraph layouts are simply matrices with 2 columns and one row for each vertex,
so the easiest is probably if you generate such a matrix yourself. If you want
to place a vertex at radius r from the center with an angle of alpha (in
radians), then you have to use the following formulae to figure out the X and
Y coordinates:
X = r * cos(alpha)
Y = r * sin(alpha)
where the Y coordinate is negated only because the Y axis of the coordinate
system of the screen is oriented from top to bottom.
You haven't mentioned whether you are using igraph from R or Python and I'm
more familar with Python, so I'll add an example in Python here:
from igraph import Layout
from math import sin, cos
def polar_layout(radii, angles):
return Layout([(r*cos(angle), r*sin(angle)) for r, angle in zip(radii, angles)])
The "polar_layout" function has to be called with two lists: one that specifies
the radius of each vertex and one that specifies the angle of each vertex. It
will then return a Layout object that can be passed to plot() as follows:
layout = polar_layout(..., ...)
plot(graph, layout=layout)
All the best,
Tamas
On 02/04, Christina Pikas wrote:
> I've got ~100 nodes assigned to various categories. I would like to end up
> with nodes of one category in the center and all the other categories
> spaced along a ring outside  like this NodeXL polar graph:
> http://www.connectedaction.net/2013/03/03/howtoplotanetworkinapolarlayoutusingnodexl/
>
> I know about star layouts (just one node in the center?) and ring or circle
> layouts.
>
> My plan was to find the layout coordinates for subgraphs for each group and
> then copy them all over, but this is proving to be even more of a hassle
> than I had originally thought.
>
> Is there an easier way?
>
> Thanks in advance,
> Christina
> _______________________________________________
> igraphhelp mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraphhelp

T.
[Prev in Thread]  Current Thread  [Next in Thread] 