SachaEpskamp / qgraph

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

coloring of dots in legend when specifying colors using "colors=..." does not work properly #4

Closed jmbh closed 8 years ago

jmbh commented 9 years ago

reproducible example:

set.seed(1) p <- 10 g <- matrix(sample(0:1, p^2, replace=T),p,p) g <- pmax(g,t(g)); diag(g) <- 0 groups <- sample(c("group1", "group2", "group3"), p, replace=T) group_cols <- numeric(p) group_cols[groups=="group1"] <- "blue" group_cols[groups=="group2"] <- "green" group_cols[groups=="group3"] <- "red" qgraph(g, colors=group_cols, groups=groups)

GiulioCostantini commented 9 years ago

Hi jmbh, The correct way to specify colors for different groups is by using a vector (group_cols) with one color by group instead of one color by node. Otherwise the first 3 colors of group_cols in your example ("green" "green" "blue" ) are interpreted as the colors of the three groups.

Here is a revised example that should work:

set.seed(1) p <- 10 g <- matrix(sample(0:1, p^2, replace=T),p,p) g <- pmax(g,t(g)); diag(g) <- 0 groups <- sample(c("group1", "group2", "group3"), p, replace=T)

group_cols <- numeric(p)

group_cols[groups=="group1"] <- "blue"

group_cols[groups=="group2"] <- "green"

group_cols[groups=="group3"] <- "red"

group_cols <- c("blue", "green", "red") qgraph(g, colors=group_cols, groups=groups)

Hope this helps,

Kind regards,

Giulio

2015-09-16 19:20 GMT+02:00 jmbh notifications@github.com:

reproducible example:

set.seed(1) p <- 10 g <- matrix(sample(0:1, p^2, replace=T),p,p) g <- pmax(g,t(g)); diag(g) <- 0 groups <- sample(c("group1", "group2", "group3"), p, replace=T) group_cols <- numeric(p) group_cols[groups=="group1"] <- "blue" group_cols[groups=="group2"] <- "green" group_cols[groups=="group3"] <- "red" qgraph(g, colors=group_cols, groups=groups)

— Reply to this email directly or view it on GitHub https://github.com/SachaEpskamp/qgraph/issues/4.

Giulio Costantini, PhD Psychology Department University of Milano-Bicocca P.zza dell'Ateneo Nuovo, 1 (U6) - room 3170d 20126 Milan (MI) Phone ++39 02.6448.3867 http://apollo.psico.unimib.it/people/costantini/

jmbh commented 9 years ago

That's it, thanks for the quick help!