我有图表,想要为节点添加各种颜色,所以我从grviz中添加了这个代码行,它改变了他拥有node = "[fillcolor = red]Canis"
的值的节点颜色,但它没有改变图中的任何颜色。 / p>
图表的其余代码:
df <- data.frame(col1 = c( "Cat", "Dog", "Bird"),
col2 = c( "Feline", "Canis", "Avis"),
stringsAsFactors=FALSE)
uniquenodes <- unique(c(df$col1, df$col2))
library(DiagrammeR)
nodes <- create_node_df(n=length(uniquenodes), nodes = seq(uniquenodes), type="number", label=uniquenodes, nodes = "[fillcolor = red]Canis")
edges <- create_edge_df(from=match(df$col1, uniquenodes), to=match(df$col2, uniquenodes), rel="related")
g <- create_graph(nodes_df=nodes, edges_df=edges, attr_theme = NULL)
render_graph(g)