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") >
时间: 2024-10-27 05:09:17