R2-29-第四次作业-饼图+箱式图

CISO 2017-11-23 16:10:34 阅读: 1285

1.Pie graph

首先将给定数据集中的中文换成英文:

QQ截图20171123160856.png

> 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)

pie.png


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"))

boxplot.png

 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2025 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号