我能夠生產具有可變binwidths一個barplot使用在R中,使用ggplot + geom_bar,你如何改變一個條的寬度?
byA<-barplot(table(A),width=B$length, space = 0,col="black")
我怎麼可能做使用ggplot一樣嗎?
我已經試過這樣:
ggplot(data.frame(table(A)), aes(x=B$Start, y=Freq, width=B$length)) +
geom_bar(aes(fill=B$length), stat="identity", position="identity")
我怎樣才能條之間擺脫了空間和改變他們的位置從0開始,而不是在X標記爲中心? (我猜這可能會讓我看到同樣的情節。)注意:我更喜歡第二張圖中的x軸值,所以沒關係。
這些都是前20行我的數據:
bin Freq
1 [0,0.78) 9
2 [0.78,0.99) 1
3 [0.99,1.07) 1
4 [1.07,1.201) 1
5 [1.201,1.211) 0
6 [1.211,1.77) 3
7 [1.77,1.95) 0
8 [1.95,2.14) 2
9 [2.14,2.15) 0
10 [2.15,2.581) 0
11 [2.581,3.04) 4
12 [3.04,3.11) 0
13 [3.11,3.22) 0
14 [3.22,3.33) 1
15 [3.33,3.58) 3
16 [3.58,4.18) 8
17 [4.18,4.29) 2
18 [4.29,4.48) 4
19 [4.48,4.62) 4
20 [4.62,4.8) 3
嘗試調整寬度 – MLavoie