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

Different patterns for arches (links) #43

Open
rbandari83 opened this issue Nov 22, 2021 · 0 comments
Open

Different patterns for arches (links) #43

rbandari83 opened this issue Nov 22, 2021 · 0 comments

Comments

@rbandari83
Copy link

Hi I have below coding for chord diagram and 2 different type of data (i.e., positive and negative ones). I used the dash pointed line for negative ones (just line around of each arches) but I want to know that how I can define different pattern for inside of each arch (link) instead of dash pointed line around them. Thanks in advance.
library(statnet)
library(circlize)
library(readxl)
data1 <- read_excel("C:
Goal Negative.xlsx
Goal posetive.xlsx
Rplot10
\SDGs\My File GM\Final Nvivo & Excel\R program\Goal negative.xlsx", col_names = FALSE)
my.data1 <- as.matrix(x =data1, nrow = 5, ncol = 5)
rownames(my.data1) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(my.data1) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
data2 <- read_excel("C:\Users\rbandari\OneDrive - Deakin University\SDGs\My File GM\Final Nvivo & Excel\R program\Goal posetive.xlsx", col_names = FALSE)
my.data2 <- as.matrix(x =data2, nrow = 5, ncol = 5)
rownames(my.data2) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(my.data2) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself

mat=rbind(my.data1,my.data2)
rownames(mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15","SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
grid.col[c("SDG2","SDG6","SDG8","SDG13","SDG15")] = c(rgb(red = 221, green = 166, blue = 58, max=255),rgb(red = 38, green = 189, blue = 226, max=255), rgb(red = 162, green = 25, blue = 66, max=255), rgb(red = 63, green = 126, blue = 68, max=255), rgb(red = 86, green = 192, blue = 43, max=255))

lwd_mat = matrix(1, nrow = nrow(mat), ncol = ncol(mat))
rownames(lwd_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15","SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(lwd_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
lwd_mat[mat < 0] = 2
border_mat = matrix(NA, nrow = nrow(mat), ncol = ncol(mat))
rownames(border_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15","SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(border_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
border_mat[mat < 0] = "red"
lty_mat =matrix(1, nrow = nrow(mat), ncol = ncol(mat))
rownames(lty_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15","SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
colnames(lty_mat) <- c("SDG2","SDG6","SDG8","SDG13","SDG15")#named by yourself
lty_mat[mat < 0] = 3

chordDiagram(mat, grid.col = grid.col, link.lwd = lwd_mat, link.lty =lty_mat, link.border = border_mat,
transparency = 0.25, annotationTrack = "grid", preAllocateTracks = list(track.height = max(strwidth(unlist(dimnames(my.data))))))
circos.track(track.index = 1, panel.fun = function(x, y) {
circos.text(CELL_META$xcenter, CELL_META$ylim[1], CELL_META$sector.index,
facing = "outside", niceFacing = TRUE, adj = c(0.4, 1))
}, bg.border = NA) # here set bg.border to NA is important

circos.clear()

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

1 participant