我通過觀察標記爲重複的URL解決了這個問題。感謝MrFlick!
我下面繪製條:
[...]
data <- structure(list(vdb, vdc, vdd, vde),
.Names = c("4K", "16K", "32K", "64K"),
class = "data.frame", row.names = c(NA, 4L))
colours <- c("green", "orange", "blue", "red")
barObj <- barplot(as.matrix(data), main=title, ylab = "IOPS (log scale)",
cex.lab = 1.2, cex.main = 1.4,
beside=TRUE, col=colours, log="y")
legend("topright", c("B", "C", "D", "E"), cex=1.3, bty="n", fill=colours)
添加以下兩行把數字上的酒吧之上。
[...]
data <- structure(list(vdb, vdc, vdd, vde),
.Names = c("4K", "16K", "32K", "64K"),
class = "data.frame", row.names = c(NA, 4L))
values = c(vdb, vdc, vdd, vde) # added line
colours <- c("green", "orange", "blue", "red")
barObj <- barplot(as.matrix(data), main=title, ylab = "IOPS (log scale)",
cex.lab = 1.2, cex.main = 1.4,
beside=TRUE, col=colours, log="y")
text(x=barObj, y=values, label=values, cex=0.9, pos=3, col="black", xpd=TRUE) # added line
legend("topright", c("B", "C", "D", "E"), cex=1.3, bty="n", fill=colours)
把數字放在條形圖上是很愚蠢的。這個情節的重點是什麼,爲什麼不製作一個數字表呢?最好在問題本身中直接包含[可重現的示例](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)。要求他人下載一個潛在危險的ZIP文件是不禮貌的。您應該簡化數據和代碼,儘可能使問題變得清晰。 – MrFlick
可能的重複:http://stackoverflow.com/questions/12481430/how-to-display-the-frequency-at-the-top-of-each-factor-in-a-barplot-in-r/12483754# 12483754 – MrFlick
感謝您對@MrFlick重複的指針,並道歉不提供可重複的示例。我通過查看您提供的重複問題來解決問題。我將以解決方案摘錄爲例。 –