Reputation: 23
New to igraph. I would like to have vertex colours be defined by another parameter, preferably continuous colours (think heatmap or grayscale).
clusters_only <- as.character(temp_df$SeqID)
v_names <- data.frame(c(unique_order, as.character(temp_df$SeqID)))
graph_order <- graph.data.frame(temp_df, directed = FALSE, vertices = v_names)
V(graph_order)[clusters_only]$size <- ? #continuous colour based on variable in temp_df
Any ideas?
Much appreciated.
Upvotes: 2
Views: 2280
Reputation: 2263
I had better luck with this syntax:
R> library(igraph)
R> g <- grg.game(100, 0.2)
R> V(g)$color <- 1:100
R> g$palette <- grey.colors(100) #### updated this line
R> plot(g)
Maybe the grammar has changed since the original answer?
Upvotes: 0
Reputation: 48061
You can use the color
attribute of vertices to specify the vertex colors. It may be a string (containing a color name known to R) or a numeric value, in which case the color will be selected from the current palette. E.g.:
library(igraph)
g <- grg.game(100, 0.2)
V(g)$color <- 1:100
palette(gray.colors(100))
plot(g)
Alternatively, you may specify the colors as the argument of plot
instead of assigning them to a vertex attribute:
plot(g, vertex.color <- 1:100)
Upvotes: 2