r - Colours don't show up in diagram -
i have code should render diagrams few colours, when code in used don't see colours
df <- data.frame(col1 = c( "cat", "dog", "bird"), col2 = c( "feline", "canis", "avis"), stringsasfactors=false) uniquenodes <- unique(c(df$col1, df$col2)) library(diagrammer) cols <- setnames(rep("green", length(uniquenodes)), uniquenodes);cols["canis"]<-"red" nodes <- create_node_df(n=length(uniquenodes), nodes = seq(uniquenodes), type="number", label=uniquenodes, fillcolor=cols) 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)
taking same code used; need change definition of nodes
nodes <- create_node_df(n=length(uniquenodes), nodes = seq(uniquenodes), type="number", label=uniquenodes, color=cols, style = "filled")
i deleted 1 parameter fillcolor=cols
, added 2 color=cols
, style="filled"
.
Comments
Post a Comment