条形图 -> 饼图 -> 环状图
作者:互联网
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)
标签:cowplot,df,library,ggplot2,环状,条形图 来源: https://www.cnblogs.com/mmtinfo/p/15839936.html