我想一個傳說附加到R. 一個情節我嘗試下面的代碼(從http://www.harding.edu/fmccown/r/拍攝)如何結合情節和傳奇?
# Define cars vector with 5 values
cars <- c(1, 3, 6, 4, 9)
# Define some colors ideal for black & white print
colors <- c("white","grey70","grey90","grey50","black")
# Calculate the percentage for each day, rounded to one
# decimal place
car_labels <- round(cars/sum(cars) * 100, 1)
# Concatenate a '%' char after each value
car_labels <- paste(car_labels, "%", sep="")
# Create a pie chart with defined heading and custom colors
# and labels
pie(cars, main="Cars", col=colors, labels=car_labels,
cex=0.8)
# Create a legend at the right
legend(1.5, 0.5, c("Mon","Tue","Wed","Thu","Fri"), cex=0.8,
fill=colors)
然而,這並不工作非常好。在餅圖(汽車,主=「汽車」,col =顏色,標籤= car_labels,cex = 0.8)行後,情節顯示爲沒有圖例:-) .......我看到的每個示例互聯網似乎有繪圖功能後傳說功能,所以看起來很怪異..............
當我嘗試執行傳說功能我得到
圖例(1.5,0.5,c(「Mon」,「Tue」,「Wed」,「Thu」,「Fri」),cex = 0.8, + fill = colors) strwidth(圖例,單位=「user」,cex = cex): plot.new尚未被調用