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

Using my own colours #23

Open
juliabergmann opened this issue Jul 18, 2018 · 3 comments
Open

Using my own colours #23

juliabergmann opened this issue Jul 18, 2018 · 3 comments

Comments

@juliabergmann
Copy link

Hi Matt,

I am wondering if it is possible to change the colours to a self-defined palette and not to some predefined palette.
My main issue is that I wish to create a chord diagram of 53 nodes so I would like to have 53 different colours.

Thank you in advance,
Julia

@mattflor
Copy link
Owner

Sure, just use the groupColors argument (here, I'm using n = 10 groups; I am not sure how much you will be able to discern with 53 groups):

library(chorddiag)
library(viridis)

n <- 10
m <- matrix(rpois(n*n, lambda = 1),
            byrow = TRUE,
            nrow = n, ncol = n)
row.names(m) <- as.character(1:n)
colnames(m) <- as.character(1:n)

groupColors <- viridis_pal()(n)           # n discrete Viridis colors
groupColors <- substr(groupColors, 0, 7)  # get rid of transparency characters ('FF')

chorddiag(m, groupColors = groupColors,
          showTicks = FALSE)              # showing ticks takes a long time if you have many groups

@mattflor
Copy link
Owner

Here's one with 53 groups. It looks ok because the matrix it pretty sparse. Also note that you should configure the groupPadding argument to use something smaller than the default if you have many groups:

library(chorddiag)
library(viridis)

n <- 53
m <- matrix(rpois(n*n, lambda = 0.1),
            byrow = TRUE,
            nrow = n, ncol = n)
row.names(m) <- as.character(1:n)
colnames(m) <- as.character(1:n)
m
groupColors <- viridis_pal()(n)           # n discrete Viridis colors
groupColors <- substr(groupColors, 0, 7)  # get rid of transparency characters ('FF')

chorddiag(m, groupColors = groupColors,
          showTicks = FALSE,              # showing ticks takes a long time if you have many groups
          groupPadding = 0.5)             # don't waste space!    

@juliabergmann
Copy link
Author

thanks a lot, also for the fast response!

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

2 participants