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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 @   天使不设防  阅读(159)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
点击右上角即可分享
微信分享提示