> For the complete documentation index, see [llms.txt](https://zpliu.gitbook.io/booknote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zpliu.gitbook.io/booknote/ggplot2/bing-tu.md).

# 饼图

## 饼图

## labels

在图片中粘贴文字

```r
> labels
[1] "A&D(16%)" "A(41%)"   "D(42.9%)"
```

## 极坐标转换

* `start`控制图片旋转

```r
coord_polar(theta = 'y',start = 20)
```

```r
noconserve$V3=factor(noconserve$V3,levels = c("A","D","all"))
labels <- paste("(", round(noconserve$V4 / sum(noconserve$V4) * 100, 1), "%)", sep = "")
labels <- paste(c("A&D", "A", "D"), labels, sep = "")
labels
ggplot(data = noconserve, aes(x = V1, y = V4, fill = V3)) +
  geom_bar(stat = "identity", position = "stack", width = 1) +
  coord_polar(theta = 'y',start = 20)+
  labs(x = "", y = "", title = "") +
  geom_text(aes(
    x = sum(noconserve$V4) / 6000,
    y=noconserve$V4 / 2 + c(0, cumsum(noconserve$V4)[-length(noconserve$V4)]),
    label = labels
  )) +
  theme(
    axis.text = element_blank(),
    panel.grid = element_blank(),
    legend.position = "none",
  )
```
