[英]How can I make legend next to my piechart in R?
我在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)
。 但這並沒有給我一個旁邊我的餅圖的傳奇。
我必須使用哪些代碼在中間的餅圖旁邊制作一個圖例?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.