R语言实战 - 基本图形- 饼图
Posted 你的踏板车要滑向哪里
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了R语言实战 - 基本图形- 饼图相关的知识,希望对你有一定的参考价值。
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") >
以上是关于R语言实战 - 基本图形- 饼图的主要内容,如果未能解决你的问题,请参考以下文章