# Igraph command

**URL:** <https://igraph.discourse.group/t/igraph-command/494>\
**Category:** Usage\
**Tags:** R\
**Created:** [22 October 2020 11:10 UTC](https://igraph.discourse.group/t/igraph-command/494 "2020-10-22T11:10:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nasrin\_Ashrafi](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/nasrin_ashrafi/32/390_2.png) [@Nasrin\_Ashrafi](https://igraph.discourse.group/u/Nasrin_Ashrafi)\
**Post date:** [22 October 2020 11:10 UTC](https://igraph.discourse.group/t/igraph-command/494/1 "2020-10-22T11:10:12Z")

</div>

Hi, I’m a beginner in working with igraph with no statistical background. I wonder if you could help me with how I can plot two-mode network data? I have 9 lines and 13 columns. I run this command:

```auto
library(igraph)
data= read.table(file.choose())
d1= as.matrix(data)
d2= graph_from_incidence_matrix(d1, weighted=TRUE)
vcount(d2)
par(mar=c(0,0,0,0))
gplot(d2,
     vertex.color=c(rep("darkblue",9),rep("pink",11)),
     edge.width=3, edge.color=ifelse(2 < E(d2)$weight, "red", "gray"))

```

---

<div class="post-metadata">

**Author:** ![IgnatiusPang](https://avatars.discourse-cdn.com/v4/letter/i/0ea827/32.png) [@IgnatiusPang](https://igraph.discourse.group/u/IgnatiusPang)\
**Post date:** [5 November 2020 21:34 UTC](https://igraph.discourse.group/t/igraph-command/494/2 "2020-11-05T21:34:46Z")

</div>

Hi Nasrin\_Ashrafi,

Please try using plot instead of ‘gplot’ instead of ‘plot’. For example,

```auto
library(igraph)
# data= read.table(file.choose())
# d1= as.matrix(data)

## Since I don't have your table, I'm generating a sample one.
## It will have values randomly chosen from the integers 0, 1, and 2
d1 <- matrix(sample(0:2, 9*13, repl=TRUE), 9, 13)

d2= graph_from_incidence_matrix(d1, weighted=TRUE)
vcount(d2)
par(mar=c(0,0,0,0))

plot(d2,
     vertex.color=c(rep("darkblue",7),rep("pink",6)),
     edge.width=3, edge.color=ifelse(1 < E(d2)$weight, "red", "gray"))

```

Alternatively, you can set the edge and node attributes within the network object itself

```auto
V(d2)$color <- c(rep("darkblue",7),rep("pink",6))
E(d2)$color <- ifelse(1 < E(d2)$weight, "red", "gray")
plot(d2, edge.width=3)

```

Yours sincerely,

Ignatius Pang
