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@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@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.

Reply via email to