[R] geom_node_point color in ggraph

Wolfgang Grond wgrond @end|ng |rom wgrond@de
Thu Apr 15 22:07:05 CEST 2021


Rui,

thanks a lot, I'll try it this way.

Best regards

Wolfgang

Am 15. April 2021 21:19:27 MESZ schrieb Rui Barradas <ruipbarradas using sapo.pt>:
>Hello,
>
>To define the colors, remove the data set name from the aesthetic.
>This
>
>aes(colour = project_all$Acronym)
>
>
>should be this
>
>aes(colour = Acronym)
>
>
>Then choose the colours in the usual ggplot way. Here is a reproducible
>
>example.
>
>
>library(igraph)
>library(ggraph)
>
>project_all <- make_graph("bull")
>vertex_attr(project_all, "Acronym", index = V(project_all)) <- "red"
>vertex_attr(project_all, "Acronym", index = V(project_all)[[3]]) <-
>"blue"
>
>ggraph(project_all, layout = "igraph", algorithm = "kk") +
>   geom_edge_link() +
>   geom_node_point(aes(colour = Acronym), size = 8) +
>   scale_color_manual(name = "Project / Projekt",
>                      values = c("blue", "red"))
>
>
>Hope this helps,
>
>Rui Barradas
>
>
>Às 15:57 de 15/04/21, Wolfgang Grond escreveu:
>> Dear all,
>> 
>> I'm joining differnts graphs to one with command graph_join from
>ggraph,
>> 
>> and try to color the nodes depending on the subgraph they come from.
>> 
>> To do that, I have these commands in my ggraph:
>> 
>> ####################################################
>> 
>> ...
>> geom_node_point(size = 8, aes(colour = project_all$Acronym)) +
>>       scale_color_discrete(name="Project / Projekt") +
>> ...
>> 
>> ####################################################
>> 
>> All works well, but
>> 
>> how to define the colors to use for the nodes?
>> 
>> Is it possible to either
>> 
>> - define the colors explicitely, or
>> 
>> - define a color palette to use?
>> 
>> Please point me to where I should look how to do it.
>> 
>> Many thanks in advance
>> 
>> Wolfgang
>> 
>> 
>> 	[[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]



More information about the R-help mailing list