2016-06-28 24 views
1

我一直在努力獲得一個能準確顯示我的數據的圖,並花了一段時間來獲得gap.plot並運行。這樣做後,我有一個標記點​​的問題。使用gap.plot創建軸中斷後標記問題

剛剛繪製我的數據結束了這一點:

Plot of abundance data, basically two different tiers of data at ~38,000, and between 1 - 50

正如你所看到的,不清晰顯示的頂部或我的圖不夠好辨東西的底部部分。

使用差距情節,我設法:

gap.plot of abundance data, 100 - 37000 missed, labels only appearing on the lower tier

的代碼爲我的兩個地塊很簡單:

plot(counts.abund1,pch=".",main= "Repeat 1") 
text(counts.abund1, labels=row.names(counts.abund1), cex= 1.5) 

gap.plot(counts.abund1[,1],counts.abund1[,2],gap=c(100,38000),gap.axis="y",xlim=c(0,60),ylim=c(0,39000)) 
text(counts.abund1, labels=row.names(counts.abund1), cex= 1.5) 

但我不知道爲什麼/不能找出爲什麼標籤(它們只是這些點表示的字母)在兩個圖中沒有被應用。

我有點不知所措,不知道該怎麼畫好這樣的東西,學習的時候從來沒有像這樣的數據。

來自這個數據的數據最初是一個大的(10,000 x 10,000矩陣),其中包含隨機分類的字母a到z,然後有替換和「形態」或「移民」,導致第一批很多字母在〜38000,以及第二批一般低於50

我得到那個矩陣得到秩豐後運行的代碼是:

##Abundance 1 
counts1 <- as.data.frame(as.list(table(neutral.v1))) 
counts.abund1<-rankabundance(counts1) 

隨着neutral.v1作爲基質。

的counts.abund1數據幀的樣子(極其格式混亂,不好意思):

rank abundance proportion plower pupper accumfreq logabun rankfreq  

a 1 38795 3.9 NaN NaN 3.9 4.6 1.9 
x 2 38759 3.9 NaN NaN 7.8 4.6 3.8 
j 3 38649 3.9 NaN NaN 11.6 4.6 5.7 
m 4 38639 3.9 NaN NaN 15.5 4.6 7.5 

,並繼續爲所有的變量。我現在只使用秩和豐度,而a,x,j,m只是適用於該變量的變量,而我想用作該圖上的標籤。

任何意見將非常感激。我無法真正縮短代碼太多或提供矩陣,因爲數據類型非常具體,就像在某種意義上的數量一樣。

正如我所提到的,我一直在使用gap.plot來創建一個軸的中斷,但如果有更好的解決方案來繪製這種類型的數據,我絕對是所有的耳朵。

真的很遺憾,這是一個混亂的問題,現在整個事情都有點亂。

回答

1

gap.plot()不繪製兩個圖,而是繪製一個繪圖,方法是減少上部分的值,繪製額外的框並重寫軸刻度標籤。因此,上部區域的y座標既不等於原始值也不等於軸刻度標籤。上部區域的實際y座標爲"original value" - diff(gap)

gap.plot(counts.abund1[,1], counts.abund1[,2], gap=c(100,38000), gap.axis="y", 
     xlim=c(0,60), ylim=c(0,39000)) 
text(counts.abund1, labels=row.names(counts.abund1), cex= 1.5) 
text(counts.abund1[,1], counts.abund1[,2] - diff(c(100, 38000)), labels=row.names(counts.abund1), cex=1.5) 

# the example data I used 
set.seed(1) 
counts.abund1 <- data.frame(rank = 1:50, 
          abundance = c(rnorm(25, 38500, 100), rnorm(25, 30, 20))) 

enter image description here

+0

真棒!不知道。非常感謝。 – Mike