1绘制
代码语言:javascript
复制ggplot(mydata)
geom_bar(aes(x=a, y=b),width = 1,stat="identity",
colour = "black",fill="#F8766D")
geom_text(aes(x=a,y = b-8,label = b),color="white")
coord_polar(theta = "x",start=0)
ylim(c(0,120))
theme_light()
theme( panel.background = element_blank(),
panel.grid.major = element_line(colour = "grey80",size=.25),
axis.text.y = element_text(size = 12,colour="black"),
axis.line.y = element_line(size=0.25),
axis.text.x=element_text(size = 13,colour="black",angle = myAngle))
2绘制不带空心的玫瑰图
代码语言:javascript
复制ggplot(diamonds,aes(x=clarity,fill=color))
geom_bar(width=1.0,colour="black",size=0.25)
coord_polar(theta = "x",start=0)
scale_fill_brewer(palette="GnBu")
guides(fill=guide_legend(reverse=TRUE,title=NULL))
ylim(c(0,12000))
theme_light()
theme( panel.background = element_blank(),
panel.grid.major = element_line(colour = "grey80",size=.25),
axis.text.y = element_text(size = 12,colour="black"),
axis.line.y = element_line(size=0.25),
axis.text.x=element_text(size = 13,colour="black",angle = myAngle))
3绘制带空心的玫瑰图
代码语言:javascript
复制> ggplot(diamonds,aes(x=clarity,fill=color))
geom_bar(width=1.0,colour="black",size=0.25)
coord_polar(theta = "x",start=0)
scale_fill_brewer(palette="Reds")
guides(fill=guide_legend(reverse=TRUE,title="Color"))
ylim(c(-2000,12000)) #这里是关键
theme_light()
theme( panel.background = element_blank(),
panel.grid.major = element_line(colour = "grey80",size=.25),
axis.text.y = element_text(size = 12,colour="black"),
axis.line.y = element_line(size=0.25),
axis.text.x=element_text(size = 13,colour="black",angle = myAngle))