用ggpuber画个实心饼图
p1 <- ggpubr::ggpie(data = subset(pie_data,year=='2020'), x = "sales", label = "category", color = "white",
fill = "category",lab.pos = "in")+
把图片背景变透明
theme(legend.position = 'none',
panel.background = element_rect(fill = "transparent"), # bg of the panel
plot.background = element_rect(fill = "transparent", color = NA), # bg of the plot
panel.grid.major = element_blank(), # get rid of major grid
panel.grid.minor = element_blank(), # get rid of minor grid
legend.background = element_rect(fill = "transparent"), # get rid of legend bg
legend.box.background = element_rect(fill = "transparent")) # get rid of legend panel bg
p1
![](https://upload-images.jianshu.io/upload_images/28826264-d50e72df0ffe27c2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
```R
p2 <- ggplot(data=subset(pie_data,year=='2021'),aes(x=0,y=sales,fill=category))+
geom_col(width=1,color='white')+
geom_text(aes(label = scales::percent(sales/sum(sales))), position = position_stack(vjust = 0.5)) +
coord_polar(theta = 'y')+
geom_col(aes(x=-1.2,y=0))+
theme(legend.position = 'none',
axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
panel.background = element_rect(fill = "transparent"), # bg of the panel
plot.background = element_rect(fill = "transparent", color = NA), # bg of the plot
panel.grid.major = element_blank(), # get rid of major grid
panel.grid.minor = element_blank(), # get rid of minor grid
legend.background = element_rect(fill = "transparent"), # get rid of legend bg
legend.box.background = element_rect(fill = "transparent")) # get rid of legend panel bg
p2
library(patchwork)
p2 +inset_element(p1, left = 0.25, bottom = 0.25, right = 0.75, top = 0.75)