饼图示例:
slices <- c(10, 12, 4, 16, 8)
lbls <- c("US", "UK", "Australia", "Germany", "France")
pct <- round(slices/sum(slices)*100)
lbls <- paste(lbls, pct) # add percents to labels
lbls <- paste(lbls,"%",sep="") # ad % to labels
pie(slices,labels = lbls, col=rainbow(length(lbls)),main="Pie Chart of Countries")
jpeg(filename="Pie chart.jpg",width=480,height=480)
plot()
dev.off()
以上代码创建空白.jpg。我应该在plot()中写什么参数......如果这是正确的。
答案 0 :(得分:2)
将pie(...)行放在plot()现在
的位置jpeg(filename="Pie chart.jpg",width=480,height=480)
pie(slices,labels = lbls, col=rainbow(length(lbls)),main="Pie Chart of Countries")
dev.off()