Closed adamlmaclean closed 6 years ago
Then, when you use chordDiagram()
, set annotationTrack = NULL
.
If I set annotationTrack = NULL
this hides both tracks --- the car "models" and the "brands". I would like to show the outer track (brands) but hide the inner track (models). Can this be done with annotationTrack
? Thanks for your help-- circlize is a great package.
Try following code:
df = read.table(textConnection("
brand_from model_from brand_to model_to
VOLVO s80 BMW 5series
BMW 3series BMW 3series
VOLVO s60 VOLVO s60
VOLVO s60 VOLVO s80
BMW 3series AUDI s4
AUDI a4 BMW 3series
AUDI a5 AUDI a5
"), header = TRUE, stringsAsFactors = FALSE)
brand = c(structure(df$brand_from, names=df$model_from), structure(df$brand_to,names= df$model_to))
brand = brand[!duplicated(names(brand))]
brand = brand[order(brand, names(brand))]
brand_color = structure(2:4, names = unique(brand))
model_color = structure(2:8, names = names(brand))
library(circlize)
gap.after = do.call("c", lapply(table(brand), function(i) c(rep(2, i-1), 8)))
circos.par(gap.after = gap.after, cell.padding = c(0, 0, 0, 0))
chordDiagram(df[, c(2, 4)], order = names(brand), grid.col = model_color,
directional = 1, annotationTrack = NULL, preAllocateTracks = list(
list(track.height = 0.02))
)
for(b in unique(brand)) {
model = names(brand[brand == b])
highlight.sector(sector.index = model, track.index = 1, col = brand_color[b],
text = b, text.vjust = -1, niceFacing = TRUE)
}
circos.clear()
You also need to remove the code which draws the model names.
Thanks for this. I do actually want the model names plotted though -- in the end I solved the problem (at least for my purposes) by hiding the brands track by coloring it white, i.e.
highlight.sector(sector.index, col = "#ffffff", border="#ffffff")
There may well be an answer to this in docs but if so, I haven't found it.
In this example: http://zuguang.de/circlize/example/grouped_chordDiagram.html
I would like to hide completely the 'model' track, only plotting the 'brand' track and the edges associated with the model track. How can this be done? Thanks a lot!