R防止饼图重叠

时间:2014-09-15 12:15:18

标签: r

我的数据是这样的:

 VariantClass   PASS_ONTARGET
  Silent            50.30
  Missense          47.00
  Nonsense           0.74
  Startloss          0.26
  Stoploss           0.74
  Frameshift-indel   0.61
  Inframe-indel      0.35

我生成饼图的代码是:

    data <- read.table(file=Infilename, header=T, sep="\t")
    png(filename=Outfilename,height=4000,width=5000,res=600)
    y<-data$PASS_ONTARGET
    color<-c("blue","green","light blue","orange","purple","red","yellow")
    names<-c(data$VariantClass)
    pie(y, labels=names, font=2, main="Variant Class Distribution", clockwise = FALSE, density = NULL, col = color, border = NULL, lty = NULL)
    legend("topright",legend=names,cex=1.0, bty="n", fill=c(color))
    dev.off()

我遇到的问题是图表上的标签相互重叠。我该如何防止这种情况?

1 个答案:

答案 0 :(得分:4)

使半径更大并缩小标签。

pie(<your other arguments>, radius = 1, cex = 0.3)

但像卡尔所说,don't use pie charts