3

I am using the PlotCirc() function of the DescTools R package to visualize a contingency table:

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

Question:

How can I rotate all the labels (left and right side) so that they spread from the circle (text base line pointing to the middle of the circle) ? I.e. the first label "ABCDEFG" should be rotated by almost -90 degrees pointing upwards, whereas the "CDEFGHI" should be rotated by roughly 45 degrees pointing a bit down and so on.

zx8754
  • 52,746
  • 12
  • 114
  • 209
user2030503
  • 3,064
  • 2
  • 36
  • 53

2 Answers2

2

I could not figure out how to do it within that package. However, it is still possible:

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)

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

mr.joshuagordon
  • 754
  • 4
  • 8
1

DescTools v0.99.8 now offers a function argument las, which does exactly the job (thanks to the author Andri Signorell).

user2030503
  • 3,064
  • 2
  • 36
  • 53