igraph-help
[Top][All Lists]

## [igraph] creating a x-y graph using plot() in python??

 From: pragya agarwal Subject: [igraph] creating a x-y graph using plot() in python?? Date: Sun, 2 Jan 2011 09:13:41 +0530

Hi,

I want to plot a graph(x/y axis) using python in igraph, similar to the graph that's drawn here using R :

http://igraph.sourceforge.net/screenshots2.html

Here they have used the function:

```
library(igraph)

g <- barabasi.game(100000)
d <- degree(g, mode="in")
dd <- degree.distribution(g, mode="in", cumulative=TRUE)
alpha <- power.law.fit(d, xmin=20)
plot(dd, log="xy", xlab="degree", ylab="cumulative frequency",
col=1, main="Nonlinear preferential attachment")
lines(10:500, 10*(10:500)^(-coef(alpha)+1))

powers <- c(0.9, 0.8, 0.7, 0.6)
for (p in seq(powers)) {
g <- barabasi.game(100000, power=powers[p])
dd <- degree.distribution(g, mode="in", cumulative=TRUE)
points(dd, col=p+1, pch=p+1)
}

legend(1, 1e-5, c(1,powers), col=1:5, pch=1:5, ncol=1, yjust=0, lty=0)
```

I know there is a plot() function in python, but I am not able to implement it effectively.
If I have got a .txt file where the first column specifies values on x-axis and the 2nd column specifies values in y-axis or probably I have got two different .txt files for both x and y axis.
Then how  should I use the plot() function to create a graph??

Thanks,
Pragya