第五期作业-R007

Adobe Freeman 2017-08-13 17:06:23 阅读: 1065

A1.用“pie”函数来绘制饼图,并学习调节相关参数。

> mydata <- c(0.12, 0.3, 0.26, 0.16, 0.04, 0.12)
> names(mydata) <- c("Blueberry", "Cherry","Apple", "Boston Cream", "Other", "Vanilla Cream")
> pie(mydata, col=gray(seq(0,1,length = 6)),clockwise = TRUE,main = "pie chart")

Screen_Shot_2017-08-13_at_15_44_28.pngScreen_Shot_2017-08-13_at_15_40_24.png



Screen_Shot_2017-08-13_at_15_47_50.pngScreen_Shot_2017-08-13_at_15_47_24.png

A2

test different parameters

pie3D(mydata,height=10)
> pie3D(mydata,height=1)
> pie3D(mydata,height=0.1)
> pie3D(mydata,height=0.1,edges= 1)
> pie3D(mydata,height=0.1,edges= 5)
> pie3D(mydata,height=0.1,edges= 10)
> pie3D(mydata,height=0.1,edges= 1000)
> pie3D(mydata,height=0.1,edges= 1000,radius= 9)
> pie3D(mydata,height=0.1,edges= 1000,radius= 1)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 1)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 5)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 10)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.1)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.0)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.2)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 45)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 180)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 90)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 10)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.1)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.5)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 1)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 2)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 20)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.1,border= "blue")
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.1,border= "black")
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.1,border= "green")
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.1,border= "purple")
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.1,border= "cyan")
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.1,border= "cyan",col= rainbow(6))
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.5,theta= 0.5,start= 0.1,border= "cyan",col= rainbow(6),labels= names)
> pie3D(mydata,height=0.1,edges= 1000,radius= 0.8,theta= 0.5,start= 0.1,border= "cyan",col= rainbow(6),labels = namesplot,explode = 0.2,labelcex = 0.75,labelcol = "green",main = "pie3D test")

Screen_Shot_2017-08-13_at_17_02_17.png

additional-fan diagram


>install.packages(plotrix)
> library(plotrix)
>mydata <- c(0.12, 0.3, 0.26, 0.16, 0.04, 0.12)
>names(mydata) <- c("Blueberry", "Cherry","Apple", "Boston Cream", "Other", "Vanilla Cream")
>namesplot <-c("Blueberry", "Cherry","Apple", "Boston Cream", "Other", "Vanilla Cream")
> fan.plot(mydata,labels = namesplot, radius = 10,main="Fan Plot",col= rainbow(length(mydata)),label.radius = 12)
> legend(x=4.5,y=1.2,namesplot, cex=0.8, fill= rainbow(length(mydata)))


 Screen_Shot_2017-08-13_at_17_35_29.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-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号