ggplot圆环图有可见扇区而不是纯色

时间:2016-06-02 22:30:51

标签: r ggplot2 geom-bar

我看到这些可见的白线表示每个计数中有多少个物体。如何删除这些?当我单独使用geom_bar但在coord_polar中显而易见时,它们不存在。

我认为这个问题可能与使用统计身份或位置填充有关,但我需要这样做,因为我的方面大小不同,并且要让百分比标签显示在正确的位置。

enter image description here

数据:

    zz <- "variable set value   group_size  value_size  pos
1   efficiency.category four_week   GREEN   44  13  6.5
2   efficiency.category four_week   GREEN   44  13  6.5
3   efficiency.category four_week   GREEN   44  13  6.5
4   efficiency.category four_week   GREEN   44  13  6.5
5   efficiency.category four_week   GREEN   44  13  6.5
6   efficiency.category four_week   GREEN   44  13  6.5
7   efficiency.category four_week   GREEN   44  13  6.5
8   efficiency.category four_week   GREEN   44  13  6.5
9   efficiency.category four_week   GREEN   44  13  6.5
10  efficiency.category four_week   GREEN   44  13  6.5
11  efficiency.category four_week   GREEN   44  13  6.5
12  efficiency.category four_week   GREEN   44  13  6.5
13  efficiency.category four_week   GREEN   44  13  6.5
14  efficiency.category total   GREEN   44  8   4.0
15  efficiency.category total   GREEN   44  8   4.0
16  efficiency.category total   GREEN   44  8   4.0
17  efficiency.category total   GREEN   44  8   4.0
18  efficiency.category total   GREEN   44  8   4.0
19  efficiency.category total   GREEN   44  8   4.0
20  efficiency.category total   GREEN   44  8   4.0
21  efficiency.category total   GREEN   44  8   4.0
22  efficiency.category four_week   YELLOW  44  24  25.0
23  efficiency.category four_week   YELLOW  44  24  25.0
24  efficiency.category four_week   YELLOW  44  24  25.0
25  efficiency.category four_week   YELLOW  44  24  25.0
26  efficiency.category four_week   YELLOW  44  24  25.0
27  efficiency.category four_week   YELLOW  44  24  25.0
28  efficiency.category four_week   YELLOW  44  24  25.0
29  efficiency.category four_week   YELLOW  44  24  25.0
30  efficiency.category four_week   YELLOW  44  24  25.0
31  efficiency.category four_week   YELLOW  44  24  25.0
32  efficiency.category four_week   YELLOW  44  24  25.0
33  efficiency.category four_week   YELLOW  44  24  25.0
34  efficiency.category four_week   YELLOW  44  24  25.0
35  efficiency.category four_week   YELLOW  44  24  25.0
36  efficiency.category four_week   YELLOW  44  24  25.0
37  efficiency.category four_week   YELLOW  44  24  25.0
38  efficiency.category four_week   YELLOW  44  24  25.0
39  efficiency.category four_week   YELLOW  44  24  25.0
40  efficiency.category four_week   YELLOW  44  24  25.0
41  efficiency.category four_week   YELLOW  44  24  25.0
42  efficiency.category four_week   YELLOW  44  24  25.0
43  efficiency.category four_week   YELLOW  44  24  25.0
44  efficiency.category four_week   YELLOW  44  24  25.0
45  efficiency.category four_week   YELLOW  44  24  25.0
46  efficiency.category total   YELLOW  44  32  24.0
47  efficiency.category total   YELLOW  44  32  24.0
48  efficiency.category total   YELLOW  44  32  24.0
49  efficiency.category total   YELLOW  44  32  24.0
50  efficiency.category total   YELLOW  44  32  24.0
51  efficiency.category total   YELLOW  44  32  24.0
52  efficiency.category total   YELLOW  44  32  24.0
53  efficiency.category total   YELLOW  44  32  24.0
54  efficiency.category total   YELLOW  44  32  24.0
55  efficiency.category total   YELLOW  44  32  24.0
56  efficiency.category total   YELLOW  44  32  24.0
57  efficiency.category total   YELLOW  44  32  24.0
58  efficiency.category total   YELLOW  44  32  24.0
59  efficiency.category total   YELLOW  44  32  24.0
60  efficiency.category total   YELLOW  44  32  24.0
61  efficiency.category total   YELLOW  44  32  24.0
62  efficiency.category total   YELLOW  44  32  24.0
63  efficiency.category total   YELLOW  44  32  24.0
64  efficiency.category total   YELLOW  44  32  24.0
65  efficiency.category total   YELLOW  44  32  24.0
66  efficiency.category total   YELLOW  44  32  24.0
67  efficiency.category total   YELLOW  44  32  24.0
68  efficiency.category total   YELLOW  44  32  24.0
69  efficiency.category total   YELLOW  44  32  24.0
70  efficiency.category total   YELLOW  44  32  24.0
71  efficiency.category total   YELLOW  44  32  24.0
72  efficiency.category total   YELLOW  44  32  24.0
73  efficiency.category total   YELLOW  44  32  24.0
74  efficiency.category total   YELLOW  44  32  24.0
75  efficiency.category total   YELLOW  44  32  24.0
76  efficiency.category total   YELLOW  44  32  24.0
77  efficiency.category total   YELLOW  44  32  24.0
78  efficiency.category four_week   RED 44  5   39.5
79  efficiency.category four_week   RED 44  5   39.5
80  efficiency.category four_week   RED 44  5   39.5
81  efficiency.category four_week   RED 44  5   39.5
82  efficiency.category four_week   RED 44  5   39.5
83  efficiency.category total   RED 44  3   41.5
84  efficiency.category total   RED 44  3   41.5
85  efficiency.category total   RED 44  3   41.5
86  efficiency.category four_week   GRAY    44  2   43.0
87  efficiency.category four_week   GRAY    44  2   43.0
88  efficiency.category total   GRAY    44  1   43.5"

data <- read.table(text=zz, header = TRUE)

生成图表的代码:

efficiency.graph <- ggplot(data, aes(x=factor(variable),
                                     y=value_size[1]/group_size[1], fill=value)) + 
      theme_bw() + 
      theme(panel.grid=element_blank()) +
      theme(axis.text=element_blank()) +
      theme(axis.ticks=element_blank()) + 
      theme(legend.position = "none") + 
      coord_polar(theta="y", direction=-1) + 
      geom_bar(width=0.4, stat="identity", position="fill") +     
      facet_grid(~set) +
      geom_text(aes(y = pos/group_size, 
                    label = paste(round(100*value_size/group_size), '%', sep=''),
                    size=8))

print(efficiency.graph)

0 个答案:

没有答案