服务热线
178 0020 3020
1.Pie graph
首先将给定数据集中的中文换成英文:
> library(ggplot2)
> library(ggthemes)
> dat <- read.csv(file.choose())
> myLabel = as.vector(dat$Code)
> myLabel = paste(myLabel,"(",round(dat$Value/sum(dat$Value)*100,2),"%)",sep="")
> ggplot(dat,aes(x="",y=Value,fill=Code))+geom_bar(stat="identity",width = 1,colour = "black")+coord_polar(theta="y")+theme_few()+labs(x="",y="",title="")+ggtitle("R-29-CC")+theme(axis.text.x = element_blank(),legend.position = "top",legend.title = element_blank(),legend.text = element_text(face = "bold"),axis.ticks = element_blank())+scale_fill_discrete(breaks=dat$Code,labels=myLabel)
2.boxplot
> library(ggplot2)
> library(ggthemes)
> library(lattice)
> dat = singer
> ggplot(dat,aes(x=voice.part,y=height,fill = voice.part))+geom_boxplot()+stat_summary(fun.y = "mean", geom = "point",shape=23,size = 3,fill="white")+ggtitle("R-29-CC")+theme_hc(bgcolor = "darkunica") +theme(legend.position = "top",legend.title = element_text(face = "bold"),legend.text = element_text(face = "bold"),axis.title.x = element_text(face = "bold"),axis.title.y = element_text(face = "bold"))
附件