PlotCirc中的标签旋转(DescTools包)

时间:2014-08-31 10:55:37

标签: r visualization desctools

我正在使用DescTools R包的PlotCirc()函数来显示列联表:

library(DescTools)

tab <- matrix(c(2,5,8,3,10,12,5,7,15), nrow=3, byrow=FALSE)
dimnames(tab) <- list(c("ABCDEFG","BCDEFGH","CDEFGHI"), c("D","E","F"))

PlotCirc( tab,
          acol = c("dodgerblue","seagreen2","limegreen","olivedrab2","goldenrod2","tomato2"),
          rcol = SetAlpha(c("red","orange","olivedrab1"), 0.5)
)

enter image description here

问题:

如何旋转所有标签(左侧和右侧)以便它们从圆圈(指向圆圈中间的文本基线)展开?即第一个标签“ABCDEFG”应该向上旋转几乎-90度,而“CDEFGHI”应该向下旋转大约45度,依此类推。

2 个答案:

答案 0 :(得分:2)

我无法弄清楚如何在该包中做到这一点。但是,它仍有可能:

tab <- matrix(c(2,5,8,3,10,12,5,7,15), nrow=3, byrow=FALSE)
dimnames(tab) <- list(c("A","B","C"), c("D","E","F"))



PlotCirc( tab,labels = NA, cex.lab = 1.0,acol = c("dodgerblue","seagreen2","limegreen","olivedrab2","goldenrod2","tomato2"),rcol =   SetAlpha(c("red","orange","olivedrab1")))



text(3,15,"ABCDEFG",srt=80)
text(11,10,"BCDEFG",srt=40)
text(13,-5,"CDEFG",srt=-30)
text(-5,-12,"DEFG",srt=60)
text(-12,-5,"EFG",srt=30)
text(-9,11,"FG",srt=-45)

http://i.stack.imgur.com/sK6Kr.png

答案 1 :(得分:1)

DescTools v0.99.8现在提供了一个函数参数las,它确实完成了这项工作(感谢作者Andri Signorell)。