circlize
circlize copied to clipboard
Wrap text of sectors names in order not to be cut off
Hi,
The code used to end up with the attached plot
is the following:
svg(filename = "../results/chordDiagram_test.svg", width = 16, height = 18)
chordDiagram(adjacencyData, annotationTrack = "grid", preAllocateTracks = 1, grid.col = grid.col, )
circos.trackPlotRegion(track.index = 1, panel.fun = function(x, y) {
xlim = get.cell.meta.data("xlim")
ylim = get.cell.meta.data("ylim")
sector.name = get.cell.meta.data("sector.index")
circos.text(mean(xlim), ylim[1] + .1, sector.name, facing = "clockwise", niceFacing = TRUE, adj = c(0, 0.5), cex = 1)
#circos.axis(h = "top", labels.cex = 0.2, sector.index = sector.name, track.index = 2, labels.niceFacing = TRUE)
}, bg.border = NA)
dev.off()
I was wondering if there is a way to wrap long text used for sector names.
You can set the global option circle.margin
in the beginning of your code:
circos.par$circle.margin = c(0.5, 0.5, 0.5, 0.5)
...
Note the radius of the circle is 1, so you will know what does 0.5 correspond to.
Thanks for the tip, it works!
Other than this, there is no way to wrap the text only for the very long labels?
Maybe you can manually wrap it like "Diabetes\nmellitus"?