SachaEpskamp / qgraph

Developmental version of qgraph
GNU General Public License v2.0
68 stars 21 forks source link

The colors of legend by groups was not worked #84

Closed dengxuebin closed 8 months ago

dengxuebin commented 9 months ago

Hi SachaEpskamp I found colors of legend by groups was not worked when I used "color" customized. The only one color was displayed. Hope your reply. Thanks a lot! The code is following: fig2 <- qgraph( wadj, layout = "spring", vsize = 3.5, groups = community_structure, edge.color = Network$results$pairwise$edgecolor, color = nodecolor_fig1$color_nb, filetype = "pdf", filename = "nobridge", threshold = 0.06, theme = "Hollywood", palette = "colorblind", label.color = "black", title = "nobridge", legend = TRUE )

community_structure [1] "Others" "Others" "Others" "Others" "Others" "Others" "Others" "Others" [9] "Others" "Others" "Others" "Others" "Others" "Others" "Others" "Others" [17] "Others" "Others" "Others" "Others" "Others" "Others" "Others" "Others" [25] "Others" "Others" "Others" "Others" "Others" "Others" "Others" "Mel"
[33] "Mel" "Mel" "Mel" "Mel" "Mel" "Mel" "Mel" "Mel"
[41] "Mel" "Anx" "Anx" "Anx" "Anx" "Anx" "Aty" "Aty"
[49] "Aty" "Aty" "Aty" "Aty" "Somat" "Somat" "Somat" "Somat" [57] "Somat" "Somat" "Somat" "Somat" "Somat" "Somat" "Somat" "Somat"

nodecolor_fig1$color_nb [1] "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" [8] "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" [15] "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" [22] "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" "#CC79A7" [29] "#CC79A7" "#CC79A7" "#CC79A7" "#F0E442" "#F0E442" "#F0E442" "#F0E442" [36] "#F0E442" "#F0E442" "#F0E442" "#F0E442" "#F0E442" "#F0E442" "#E69F00" [43] "#E69F00" "#E69F00" "#E69F00" "#E69F00" "#56B4E9" "#56B4E9" "#56B4E9" [50] "#56B4E9" "#56B4E9" "#56B4E9" "#D55E00" "#D55E00" "#D55E00" "#D55E00" [57] "#D55E00" "#D55E00" "#D55E00" "#D55E00" "#D55E00" "#D55E00" "#D55E00" [64] "#D55E00"

the legend by group is like image

SachaEpskamp commented 8 months ago

Hi! Try removing the groups argument. If you use groups, then color is used to indicate the color per group not per node.

dengxuebin commented 7 months ago

Hi! Try removing the groups argument. If you use groups, then color is used to indicate the color per group not per node.

Hi, but I need groups, based on your reply, I got the picture below ,which had only one legend:

image

what I need is like the picture below: image

I think the key is how to map the "groups/legends" to the "color=nodecolor_fig1$color_nb"

SachaEpskamp commented 7 months ago

In this case you should only supply a vector of 6 colors to the color argument (one per group).