Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jmbh opened this issue Sep 16, 2015 · 2 comments

Comments

@jmbh
Copy link
Collaborator

jmbh commented Sep 16, 2015

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
Copy link
Collaborator

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
#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
Copy link
Collaborator Author

jmbh commented Sep 16, 2015

That's it, thanks for the quick help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants