0

I would like to add a huge curly bracket to a plot in R, in order to unite some of the elements there. My problem: using text() and it's argument cex makes the bracket really thick as well:

# At first create data
ges <- 94969
alle <- c(6379/ges,22264/ges,11018/ges,2079/ges,444/ges,7268/ges,2204/ges,322/ges,100/ges,9236/ges,1872/ges,5934/ges,4428/ges,14689/ges,3631/ges,1243/ges,1858/ges)
pct <- round(alle/sum(alle)*100, digits=2)
pct1 <- pct; pct1[pct1 < 0.3] <- NA
pct2 <- pct; pct2[pct2 >= 0.3] <- NA
pctgr <- c(round((6379+22264+11018+2079+444+7268+2204+322+100)/ges*100, 2), round((9236+1872+5934+4428+14689)/ges*100, 2), round((3631+1243+1858)/ges*100, 2))
lbls <- c(NA,NA,NA,NA, paste0("Gras- und\n Staudenfluren\n", pctgr[1], " %"),NA,NA,NA,NA,NA,NA,
          paste0("Wälder und Forste\n", pctgr[2], " %"),NA,NA,NA,
          paste0("Sonstige\n", pctgr[3], " %"))

# Then find out the angles of the slices (in radiant) for labelling:
library(plotrix)
pie(alle, density = c(NA,NA,NA,8,NA,8,8,NA,8,NA,NA,8,NA,NA,NA,NA,NA), labels = "",
    col=c("gold","gold3","goldenrod","red","gold4","red","red","darkorange","red","chartreuse4","forestgreen","red","green3","green4","tomato1","tomato2","tomato3"))
winkel <- floating.pie(0, 0, radius = 0.5, alle,
                       col=c("gold","gold3","goldenrod","red","gold4","red","red","darkorange","red","chartreuse4","forestgreen","red","green3","green4","tomato1","tomato2","tomato3"))

# Then plot the pie and label it:
windows(width = 10, height = 8)
pie(alle, density = c(NA,NA,NA,8,NA,8,8,NA,8,NA,NA,8,NA,NA,NA,NA,NA), labels = "",
    col=c("gold","gold3","goldenrod","red","gold4","red","red","darkorange","red","chartreuse4","forestgreen","red","green3","green4","tomato1","tomato2","tomato3"))
pie.labels(0, 0, angles = winkel, labels = lbls, radius = 1.04)
pie.labels(0, 0, angles = winkel, labels = pct1, radius = 0.68, cex = 0.75, font =2)
pie.labels(0, 0, angles = winkel, labels = pct2, radius = 0.58, cex = 0.75, font = 2)

# Finally unite some slices with brackets
text(-0.76, 0.4, "{", srt = -25, cex = 25)
text(-0.3, -0.78, "{", srt = 71, cex = 25)

But, uhh, how ugly those brackets are! Isn't there a way to just strech them - not to magnify them overall?

mattu
  • 318
  • 2
  • 16
  • 1
    I think the question is how to stretch them, not how to add them. Now idea how to do that, but in C_Z's link you can see that changing the family fond may help. That aside, why bother with adding brackets if you could perhaps make a prettier graph more easily like this: http://stackoverflow.com/questions/26748069/ggplot2-pie-and-donut-chart-on-same-plot? – Wave Jul 28 '16 at 19:39
  • @Wave Wow that's quite cool - but doesn't seem easier at all. If I got some time, I will get to know this stuff... – mattu Jul 28 '16 at 23:25
  • @C_Z_ Yeah, this basically answers my question, but it somehow doesn't work. I always get the error: font ... not found in Windows font database, allthough I checked a few times and tried a dozen different spellings (which appeared somewhere) and some different fonts. – mattu Jul 29 '16 at 00:17
  • @mattu You probably need to install the font – C_Z_ Jul 29 '16 at 15:27
  • @C_Z no, I installed it right before, even restarted the computer. It doesn't work with "Times New Roman" either. It seems as if R looked at the wrong place for the fonts. But I don't know how to tell it, where to look. – mattu Jul 29 '16 at 17:41

0 Answers0