条形图 -> 玫瑰图 -> 饼图 -> 环状图

library(ggplot2)
library(cowplot)

df<-data.frame(K=LETTERS[1:4],V=c(10,20,100,60))

p1<-ggplot(df,aes(x=K,y=V,fill=K))+geom_bar(stat = 'identity')+
  labs(title="P1")

p2<-ggplot(df,aes(x=K,y=V,fill=K))+geom_bar(stat = 'identity')+
  coord_polar()+
  labs(title="P2")

p3<-ggplot(df,aes(x=K,y=V,fill=K))+geom_bar(stat = 'identity')+
  coord_polar(theta = "y")+ 
  labs(title="P3")

p4<-ggplot(df,aes(x="",y=V,fill=K))+geom_bar(stat = 'identity')+
  coord_polar(theta = "y")+ 
  labs(title="P4")

p5<-ggplot(df,aes(x="",y=V,fill=K))+geom_bar(stat = 'identity')+
  coord_polar()+
  labs(title="P5")

p6<-ggplot(df,aes(x="",y=V,fill=K))+geom_bar(stat = 'identity')+
  coord_polar(theta = "y")+
  geom_rect(aes(xmin=0,ymin=0,xmax=0,ymax=0))+
  labs(title="P6")

cowplot::plot_grid(p1,p2,p3,p4,p5,p6)

 

posted @ 2022-01-24 16:25  天使不设防  阅读(147)  评论(0编辑  收藏  举报