igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] plot graph with color of nodes as node out-degree + colorba


From: George Vega Yon
Subject: Re: [igraph] plot graph with color of nodes as node out-degree + colorbar
Date: Mon, 31 Oct 2016 09:33:49 -0700

Hi there,

Here is an example using netdiffuseR::drawColorKey (either from CRAN or http://github.com/USCCANA/netdiffuseR), the color key is on the right, but if you want you can take that function and tweak it a little bit so you can have it on the bottom.

HIH

set.seed(1231)

library(igraph)
library(netdiffuseR)

all <- barabasi.game(100, m=2)

indegree<-degree(all, v = V(all), mode = c("in"))
outdegree<-degree(all, v = V(all), mode = c("out"))

V(all)$size <- (indegree+2)/2
V(all)$frame.color <- "white"
l<-layout_with_fr(all)
E(all)$arrow.size <- .09
E(all)$edge.color <- "gray80"
E(all)$width <- 1+E(all)$weight/max(E(all)$weight)

# Color scale [0,1]
col <- (indegree - min(indegree))/(max(indegree) - min(indegree))

# Color using blues9
V(all)$color<- rgb(colorRamp(blues9)(col), maxColorValue = 255) # rainbow(length(outdegree))[rank(outdegree)]

# pdf(paste(dr[1],year[1],"-",year[length(year)],field[1],"allnet.pdf"))

plot(all, layout=l,vertex.label=NA)
netdiffuseR::drawColorKey(
  indegree, nlevels=5,
  color.palette=colorRampPalette(blues9)(5),
  main="Indegree")
# dev.off()


George G. Vega Yon
+1 (626) 381 8171
http://cana.usc.edu/vegayon

On Sun, Oct 30, 2016 at 6:46 AM, Giulia Rossello <address@hidden> wrote:
Dear all,
I am trying to plot a graph using a color scale corresponding to node's out-degree.
Moreover, I would like to create a colorbar at the bottom of the plot for with the corresponding color scale of node's out-degree.
Here what I am doing:

#ALL
indegree<-degree(all, v = V(all), mode = c("in"))
outdegree<-degree(all, v = V(all), mode = c("out"))

V(all)$size <- indegree+2
V(all)$frame.color <- "white"
l<-layout_with_fr(all)
E(all)$arrow.size <- .09
E(all)$edge.color <- "gray80"
E(all)$width <- 1+E(all)$weight/max(E(all)$weight)
V(all)$color<-rainbow(length(outdegree))[rank(outdegree)]

pdf(paste(dr[1],year[1],"-",year[length(year)],field[1],"allnet.pdf"))

plot(all, layout=l,vertex.label=NA)
dev.off()


Do you have some suggestions?
Thank you in advance

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help


Attachment: Rplot01.png
Description: PNG image


reply via email to

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