Closed cardosan closed 7 years ago
Hi, the support for link.arr.col
as a data frame is missing. I only considered it when the first argument is a matrix while I totally forgot to test it when the first argument is a data frame.
Currently, you can set link.arr.col
as a color vector which has the same order as df
. link.arr.col
as a data frame will be supported very soon.
chordDiagram(df,
directional = 2,
direction.type = c("diffHeight", "arrows"),
link.arr.col = c("black", rep("white", nrow(df) - 1))
)
Hi, I have updated the package, now link.arr.col
as data frame is supported now.
indeed it works now, thanks!
Hi, jokergoo this is my code and there is some problem in fill "follow" in boundary also mow to represent season in separate network flowing line please help me!!
library(circlize)
export_dist <- c("Kailali","Kathmandu","Bardia","Kathmandu","Bardia","Kathmandu","Dolakha","Bajhang","Kailali","Kailali","Bardia","Sagaematha","Kailali","Kathmandu","Kathmandu","Kathmandu","Bardia","Mahendranagar","Bardia","Sanja","Salleri","Jajarkot","Bajura")
import_dist <- c("Butwal","Bardia","Sagarmatha","Butwal","Bajhang","Bajhang","Lalitpur","Kathmandu","Lalitpur","Lalitpur","Mahendranagar","Kailali","Butwal","Kathmandu","Dolakha","Butwal","Lalitpur","Butwal","Lalitpur","Lalitpur","Vojpur","Vojpur","Dolakha")
flow <- c(2000,65780,78010,851,35353,845,738,120788,245900,90002,4426,6870,152681,78114,32591,19274,10915,23100,6275,4544,8750,9800,1349)
season<- c("Spring","Summer","Winter","Autumn","Summer","Winter","Autumn","Spring","Summer","Winter","Autumn","Summer","Winter","Autumn","Summer","Winter","Autumn","Summer","Winter","Autumn","Spring","Summer","Winter")
df <- data.frame(export_dist, import_dist, flow,stringsAsFactors = FALSE)
dist = unique(c(df[[1]], df[[2]]))
color <- c("#E41A1C","#800000","#ff8c00","#ffd700","#008000","#00bfff","#377EB8",
"#ff69b4","#800080","#4b0082","#000000","#800000","#E8ECE7","#7109D3","#5F4974")
df1 <- data.frame(dist, color,stringsAsFactors = FALSE)
circos.clear()
circos.par(start.degree = 90, gap.degree = 5, track.margin = c(-0.1, 0.1), points.overflow.warning = FALSE)
par(mar = rep(0, 4))
chordDiagram(x = df[1:2],log10(df[3]), grid.col = color, transparency = 0.25,
order = dist, directional = 1,
direction.type = c("arrows", "diffHeight"), diffHeight = -0.04,
annotationTrack = c("grid","axis"), annotationTrackHeight = c(0.05, 0.1),
link.arr.type = "big.arrow", link.sort = TRUE, link.largest.ontop = TRUE)
circos.trackPlotRegion(
track.index = 1,
bg.border = NA,
panel.fun = function(x, y) {
xlim = get.cell.meta.data("xlim")
sector.index = get.cell.meta.data("sector.index")
dist = df1$dist[df1$dist == sector.index]
circos.text(x = mean(xlim), y = 4.4,
labels = dist, facing = "bending", cex = 1, niceFacing = TRUE, adj = c(0.5, 0))
}
)
for(i in seq_len(nrow(res))) {
circos.text(x = res$x1[i] - res$value[i]/2, y = 0.5, round(10^(res$value[i])), facing = "inside",
niceFacing = TRUE, adj = c(0.5, 0.5), cex = 0.5, col = "white", sector.index = res$rn[i], track.index = 1)
circos.text(x = res$x2[i] - res$value[i]/2, y = 0.5, round(10^(res$value[i])), facing = "inside",
niceFacing = TRUE, adj = c(0.5, 0.5), cex = 0.5, col = "white", sector.index = res$cn[i], track.index = 1)
}
this is look like
as example if I try to use link.arr.col just get white arrows for all the links using the tutorial as MWE (tried also in my own data with a dataframe passed with same results) :
I also get some 50 warnings like:
Is it a bug or am I wrong in something?