我用下面的代码在R中制作了一个饼图:
#make slices
slices <- c(19, 26, 55)
# Define some colors
colors <- c("yellow2","olivedrab3","orangered3")
# Calculate the percentage for each day, rounded to one decimal place
slices_labels <- round(slices/sum(slices) * 100, 1)
# Concatenate a '%' char after each value
slices_labels <- paste(slices_labels, "%", sep="")
# Create a pie chart with defined heading and custom colors and labels
pie(slices, main="Sum", col=colors, labels=slices_labels, cex=0.8)
# Create a legend at the right
legend("topright", c("DH","UT","AM"), cex=0.7, fill=colors)
但我想要我的饼图旁边有说明文字。我也尝试了以下代码:legend("centreright", c("DH","UT","AM"), cex=0.7, fill=colors)
。
但这并没有在我的饼图旁边给我一个说明文字。
我应该使用哪个代码才能让我的饼图中间有说明文字?
lengend
不识别"centreright"
。请参阅?legend
了解详情。使用legend("right", c("DH","UT","AM"), cex=0.7, fill=colors)
是否能得到所需结果? - Jaap