circlize icon indicating copy to clipboard operation
circlize copied to clipboard

Wrap text of sectors names in order not to be cut off

Open elpavlos opened this issue 2 years ago • 4 comments

Hi,

The code used to end up with the attached plot chordDiagram_test

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.

elpavlos avatar Jul 22 '22 13:07 elpavlos

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.

jokergoo avatar Jul 27 '22 10:07 jokergoo

Thanks for the tip, it works!

Other than this, there is no way to wrap the text only for the very long labels?

elpavlos avatar Aug 10 '22 09:08 elpavlos

Maybe you can manually wrap it like "Diabetes\nmellitus"?

jokergoo avatar Sep 01 '22 14:09 jokergoo