Open juliabergmann opened 6 years ago
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
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!
thanks a lot, also for the fast response!
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