[R] ggraph and changing colors in geom_node_arc_bar
mon|c@p@|@|ovejoy @end|ng |rom gm@||@com
Thu Apr 23 19:34:07 CEST 2020
I am not sure if anybody was able to tackle this subject, but finally after
hours of trolling the internet i came to this quite ugly solution - which
is partial but at least it changes the colors.
So, without further ado here you go:
# i hope i remembered all the pertinent libraries i needed.
gr <- graph_from_data_frame(flare$edges, vertices = flare$vertices)
palette1 <- colorRampPalette(c("darkviolet","orange", "forestgreen",
hex <- palette1(252)
gr <- gr %>%
mutate(hex = ifelse(name, as.character(myHSB$hex)[shortName], NA)) %>%
mutate(hex = .N()$hex[to] == 'hex')
gr1 <- gr
gr1 <- gr1 %>%
laygr<- create_layout(gr1, layout = 'partition', circular=TRUE)
colsgr <- laygr$hex
ggraph(gr1, layout = 'partition', circular = TRUE) +
This code does actually changes the node colors, although it is still not
very clear in which order .... i tried different orders / sort solutions,
none very exciting. But i did change the colors. If you have other ideas
how to do it, i will very much welcome it.
On Wed, Apr 22, 2020 at 8:31 AM Monica Palaseanu-Lovejoy <
monicapalalovejoy using gmail.com> wrote:
> I am playing with the ggraph that is amazing. But i don't quite understand
> some of the options it has. For example:
> gr <- graph_from_data_frame(flare$edges, vertices = flare$vertices)
> l <- ggraph(gr, layout = 'partition', circular = TRUE)
> l + geom_node_arc_bar(aes(fill = depth)) +
> This will give a nice graph in shades of blue.
> But if i want to change the fill aesthetic with a grey scale for example:
> l + geom_node_arc_bar(aes(fill = grey(seq(0,1,length=252)))) +
> coord_fixed() +
> theme(legend.position = "none")
> This will give a graphic with set colors that definitely are not on a grey
> scale. So i am missing a piece in my code.
> I tried to add scale_edge_fill_manual(values= grey(seq(0,1,length=252)))
> but to no avail, and besides this has to do with edges and not nodes. So
> this is not the solution.
> What i am doing wrong, or what i am missing from my command?
> Also i am interested how the graph and ggraph plots, in the sense in what
> order is the data plotted? I am interested in that because i may want to
> set up either colors or widths of edges separately from my graph data for
[[alternative HTML version deleted]]
More information about the R-help