Assign different color in same section of Chord diagram in R
0
0
Entering edit mode
3 days ago

Hi all,

I'm making a chord diagram in R, and have question on assigning color. You can easily replicate with my code below. What I'm trying to do is to assign two different color in same section.

set.seed(999)
mat = matrix(sample(18, 18), 3, 6) 
rownames(mat) = paste0("S", 1:3)
colnames(mat) = paste0("E", 1:6)

col_mat = rand_color(length(mat), transparency = 0.5)
dim(col_mat) = dim(mat)
chordDiagram(mat, grid.col = grid.col, col = col_mat)

If you run my code, I get value of 8 for E4 of the column and S2 of the row, and plot shows only single flow with single color. What I want to do here is to seperate them into two colors (e.g. black and yellow) in order to show even though they belong to same pair (E4-S2), they are originated from different location (e.g. E4(from US)-S2 -- Black, E4(from Russia)-S2 -- Yellow).

Any brilliant idea to show this would be welcome! Thank you in advance

Chart R Diagram Plot Chord • 277 views
ADD COMMENT
0
Entering edit mode

Something like this ?

ADD REPLY
0
Entering edit mode

Thank you for the comment! Not like this assigning color in grid. I want to color differently their links.

ADD REPLY
0
Entering edit mode

In your example there is no information about this sub category you are mentioning using country names. The best would be to redesign your colnames with your country names, assigning each country a color and show country groups (E1, E2...) using highlight.sector

ADD REPLY

Login before adding your answer.

Traffic: 1656 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6