2016-01-20 76 views
1

我使用使得直方圖中的R太長:R:切斷酒吧是爲y軸

hist(SOME_MATRIX[,4],breaks=500,ylim = c(0,1000)) 

但我的條比我給y軸的範圍高得多( 0 - 1000)。有沒有辦法使用「hist()」來切斷最大值的鋼筋呢?

+0

是它的誤導性,但對於這個情節,我不感興趣吧多久是。我知道他們很大,但這不是我想表現的。在我更感興趣的劇情中還有其他一些東西,所以我想在y = 1000時剪下它們。 – Abdel

回答

2

隨着在評論中討論的注意事項,這裏是如何切斷棒1000:

# Save plot data in an object 
x=hist(rnorm(1e5),breaks=50,ylim = c(0,1000)) 

# Cut off counts at 1000 
x$counts[x$counts>1000] = 1000 

# Re-plot histogram. Max of y-range is > 1000 to show cutoff. 
plot(x, ylim=c(0,1500)) 

enter image description here