R语言实战 - 基本图形(2)- 饼图
2. 饼图
> par(mfrow=c(2, 2))
> slices <- c(10, 12, 4, 16, 8)
> lbls <- c("US", "UK", "AUS", "GER", "FRA")
>
> pie(slices, labels=lbls, main="simple pie chart")
>
> pct <- round(slices/sum(slices)*100)
> lbls2 <- paste(lbls, " ", pct, "%", sep="")
> pct
[1] 20 24 8 32 16
> lbls2
[1] "US 20%" "UK 24%" "AUS 8%" "GER 32%" "FRA 16%"
> pie(slices, labels=lbls2, col=rainbow(length(lbls2)), main="pie chart with percentages")
>
> library(plotrix)
> pie3D(slices, labels=lbls, explode=0.1, main="3D pie chart")
>
> mytable <- table(state.region)
> lbls3 <- paste(names(mytable), "\n", mytable, sep="")
> pie(mytable, labels=lbls3, main="pie chart from a table\n (with sample sizes)")
>

> library(plotrix)
> slices <- c(10, 12, 4, 16, 8)
> lbls <- c("US", "UK", "AUS", "GER", "FRA")
> fan.plot(slices, labels=lbls, main="fan plot")
>

posted on 2017-09-24 17:45 你的踏板车要滑向哪里 阅读(414) 评论(0) 收藏 举报
浙公网安备 33010602011771号