Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205372

How to plot a network degree to node size and eigenvector to x axis and an attribute to y axis in igraph in R

$
0
0

I would like to set my network nodes size to degree centrality and the distribution on the x axis to eigenvector centrality while I distribute an attribute on the y axis. I have the following code:

    u <- layout_with_dh(G1)

Aff <- "dashed"
Inf <- "solid"
Trig <- "dotted"
edge.lty = E(G1)$lty <- E(G_Network)$Type

start <- ends(G1, es = E(G1), names = F) [, 1]
edge.col <- V(G1)$color[start]

el <- c("Magenta", "olive drab", "spring green", "coral", "golden rod", "corn flower blue", "cyan", "Brown")
V(G1)$color <- el[V(G1)$Property]

EG <- eigen_centrality(G1, directed = T, scale = T, weights = NULL)


plot(EG, log = "xy", x = 0:max(EG), y = V(G1)$Pro, pch = 19, cex = 1, edge.width = 2, edge.arrow.size = .9, vertex.label.cex = 1, vertex.label.color = "black", vertex.label.font = 2, edge.curved = .5, edge.lty = E(G1), vertex.size = 3*igraph::degree(G1, mode = "out"), edge.color = edge.col, rescale = F, layout = u*1.3)
plot()

Everything runs except the last code block. What do I need to do?

here is a printable sample of the network using 'dput(G1)' and a print of the graph:

structure(list(22, TRUE, c(0, 1, 3, 5, 4, 4, 3, 9, 11, 3, 13, 15, 16, 14, 18, 20, 20), c(1, 2, 4, 4, 6, 7, 8, 10, 12, 13, 14, 13, 17, 16, 19, 16, 21), c(0, 1, 2, 6, 9, 4, 5, 3, 7, 8, 10, 13, 11, 12, 14, 15, 16), c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10, 13, 15, 12, 14, 16), c(0, 1, 2, 2, 5, 7, 8, 8, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 14, 15, 15, 17, 17), c(0, 0, 1, 2, 2, 4, 4, 5, 6, 7, 7, 8, 8, 9, 11, 12, 12, 14, 15, 15, 16, 16, 17 ), list(c(1, 0, 1), structure(list(), .Names = character(0)), list(name = c("P702", "P617", "P616", "P619", "P701", "P212", "P608", "P625", "P807", "P623", "P101", "P613", "P801", "P606", "P603", "P602", "P615", "P252", "P251", "P238", "P604", "P624" ), Property = c(7L, 6L, 6L, 7L, 7L, 2L, 6L, 6L, 8L, 6L, 1L, 6L, 8L, 6L, 6L, 6L, 6L, 2L, 2L, 2L, 6L, 6L), Pro = c(5, -4, 7, -6, 6, 2, 3, -5, -4, 2.5, 1.6, 6, 3, 1, -2, -5, 4.5, 2, -3, 2, 2, 1)), list(Type = c("Trig", "Aff", "Inf", "Inf", "Aff", "Aff", "Trig", "Inf", "Inf", "Inf", "Aff", "Aff", "Inf", "Inf", "Aff", "Inf", "Inf"))), ), class = "igraph") IGRAPH 0856078 DN-- 22 17 -- + attr: name (v/c), Property (v/n), Pro (v/n), Type (e/c) + edges from 0856078 (vertex names): [1] P702->P617 P617->P616 P619->P701 P212->P701 P701->P608 P701->P625 P619->P807 P623->P101 P613->P801 P619->P606 P606->P603 P602->P606 [13] P615->P252 P603->P615 P251->P238 P604->P615 P604->P624

Thanks. personally, I prefer perusing the table version, I am new to r and unsure how to attach it, but here:

Vertex.1 Vertex.2 Type

P702 P617 Trig
P617 P616 Aff
P619 P701 Inf
P212 P701 Inf
P701 P608 Aff
P701 P625 Aff
P619 P807 Trig
P623 P101 Inf
P613 P801 Inf
P619 P606 Inf

P606 P603 Aff
P602 P606 Aff
P615 P252 Inf
P603 P615 Inf
P251 P238 Aff
P604 P615 Inf
P604 P624 Inf

and the vertices sample data:

Vertex Property Pro

P702 7 5.0
P617 6 -4.0
P616 6 7.0
P619 7 -6.0
P701 7 6.0
P212 2 2.0
P608 6 3.0
P625 6 -5.0
P807 8 -4.0
P623 6 2.5

P101 1 1.6
P613 6 6.0
P801 8 3.0
P606 6 1.0
P603 6 -2.0
P602 6 -5.0
P615 6 4.5
P252 2 2.0
P251 2 -3.0
P238 2 2.0

P604 6 2.0
P624 6 1.0


Viewing all articles
Browse latest Browse all 205372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>