2017-09-14 119 views
0

我有一個數據集,我想用barplot()將其可視化。我的問題是,爲什麼一些標籤而不是顯示時附加text()以及如何解決這個問題?barplot中缺少標籤

例如,這是我的表

table(test$Freq) 

    2 3 4 5 6 7 8 9 10 11 12 14 16 44 
6338 2544 1072 394 102 29 11 9 5 2 3 1 1 1 

而下面barplot將錯過第一個標籤:

barplot(table(test$Freq)) 
text(x = xx, y = test$Freq, label = test$Freq, pos = 3, cex = 0.8, col = "red") 

enter image description here

+2

因爲文本被繪製在圖的「外部」。試試這個:barplot(table(test $ Freq),ylim = c(0,8000) – Wave

回答

2

它看起來像文本正在被繪製之外的圖形。

當您致電barplot時,請嘗試調整ylim的值。這應該可以解決你的問題。