2013-10-14 164 views
0

這裏是我生成矩形圖的代碼,我希望將x和y軸標記爲下面指定的名稱,而不會與標籤「Index」和「 NA「,如下所示。有什麼辦法可以刪除NA和索引標籤或指定我最初想要的標籤嗎?分別去除NA和索引標籤的X軸和Y軸

dat <- data.frame(x1=c(1,27,154.94056), 
        x2=c(27,154.94056,155.27056), 
        y=c(0.21294542,0.10480005,0.11760634)) 

> dat 
#  x1  x2   y 
#1 1.0000 27.0000 0.2129454 
#2 27.0000 154.9406 0.1048001 
#3 154.9406 155.2706 0.1176063 

with(dat,plot(NA,xlim=c(min(x1),max(x2)),ylim=c(min(y),max(y)+.15),type="n")) 
with(dat,rect(x1,y,x2,y+0.1)) 
title(xlab="chrX Position", ylab="Divergence") 

enter image description here

回答

0

plot,設置ylab=''和​​:

with(dat, plot(NA, xlim=c(min(x1),max(x2)), 
        ylim=c(min(y),max(y)+.15), 
        type="n", xlab='', ylab='')) # <- specify xlab and ylab here 
with(dat, rect(x1,y,x2,y+0.1)) 
title(xlab="chrX Position", ylab="Divergence") 

enter image description here