我无法在我的饼图周围正确显示标签 - 无论我选择构建它的方向,并且经过多次摆弄变量后,标签都与我的切片方向相反(顺时针方向)图形构造逆时针,反之亦然。)
> piedata
Source: local data frame [15 x 4]
Groups: Array [3]
Array variable value position
<fctr> <fctr> <dbl> <dbl>
1 Array 1 Empty 13.28 6.640
2 Array 1 FAM-Negative 34.28 30.420
3 Array 1 WT 6.45 50.785
4 Array 1 MUT 2.64 55.330
5 Array 1 HET 43.16 78.230
6 Array 2 Empty 19.63 9.815
7 Array 2 FAM-Negative 45.31 42.285
8 Array 2 WT 4.49 67.185
9 Array 2 MUT 1.37 70.115
10 Array 2 HET 28.81 85.205
11 Array 3 Empty 2.64 1.320
12 Array 3 FAM-Negative 52.34 28.810
13 Array 3 WT 4.39 57.175
14 Array 3 MUT 0.98 59.860
15 Array 3 HET 39.26 79.980
library(ggplot2)
library(ggrepel)
pieplot <- ggplot(piedata, aes(x = factor(1), y = value, fill = variable)) +
geom_bar(stat = "identity", width = 1) +
coord_polar(theta = "y", direction = -1) +
geom_text_repel(aes(x = 1.4, y = piedata$position, label = piedata$value), size = 3) +
scale_fill_manual(values = plotcolors[4:8]) +
facet_grid(.~Array, labeller = label_value) +
labs(fill = "Array Yield") +
theme(axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
panel.spacing = unit(8.25, "lines"),
legend.position = "left")
就我所知,这就产生了这样的结果:
编辑:位置来自以下内容,我在其他几个主题中看到了最佳格式计算
piedata <- piedata %>% group_by(Array) %>% mutate(position = cumsum(value) - value/2)