简体   繁体   English

r chord-diagram circlize --> 旋转名称

[英]r chord-diagram circlize --> rotating names

I am writing because I would like to get some help with a plot in R, using the package circlize, please.我写这篇文章是因为我想在 R 中获得一些帮助,请使用包 circlize。

I am trying to make a chord diagram, and I could make it, but the names on the plot are overlapped,我正在尝试制作和弦图,我可以制作,但是情节上的名称重叠,

在此处输入图片说明

then I tried with a code that I picked up from: and I got the same plot, but with the names repeated, and overlapped on each other enter image description here然后我尝试使用我从中获取的代码:并且我得到了相同的情节,但是名称重复并且彼此重叠在此处输入图像描述

the code that I am using for my plot is我用于我的情节的代码是

chordDiagram(as.matrix(naxo2)
         ,grid.border = 1,
         grid.col = NULL,
         transparency = 0.5,
         preAllocateTracks = 0)

and the data frame already has the names included in the matrix that I am using.并且数据框已经包含在我使用的矩阵中的名称。

what I would like to get is a plot in which the names appear in a 90 degrees to avoid the overlapping.我想得到的是一个情节,其中名称以 90 度出现以避免重叠。

Any help is very welcome, and thanks in advance!非常欢迎任何帮助,并提前致谢!

PS: I also tried the another solution that was posted here, but I did not work for me ( R: Adjusting Labels in circlize diagram ) PS:我也尝试了这里发布的另一种解决方案,但我没有为我工作( R:调整圆形图中的标签

Please next time provide the data needed to reproduce your example.请下次提供重现您的示例所需的数据。

The idea is to plot the diagram first without labels, and then add the text selecting for the argument facing one of the options that rotate the labels, eg clockwise .这个想法是首先在没有标签的情况下绘制图表,然后添加文本选择facing旋转标签的选项之一的参数,例如clockwise Here one example这是一个例子

data("cars")

# Clockwise labels may require increasing the canvas margins
circos.par(canvas.xlim=c(-1.5,1.5),canvas.ylim=c(-1.5,1.5))
df.test=df[,c(1,2)]

cDiag = chordDiagram(df.test, 
             #directional = 2, 
             annotationTrack = "grid")

for(si in get.all.sector.index()) {
  xlim = get.cell.meta.data("xlim", sector.index = si, track.index = 1)
  ylim = get.cell.meta.data("ylim", sector.index = si, track.index = 1)
  circos.text(mean(xlim),ylim[1], si, sector.index = si, track.index = 1, 
              facing = "clockwise", 
              cex=0.8, 
              adj=c(-1,0),
              niceFacing = TRUE)
  circos.axis(h = 0,
              major.at = c(0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5) ,
              labels.cex = 0.2,labels.facing = "inside", 
              sector.index = si, track.index = 1)
}


circos.clear()

和弦图顺时针标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM