2015-07-05 123 views
0

我有一個情節,我已經添加了第二行來使用lines()函數,但添加的行不符合默認的軸範圍,所以我想增加兩個軸的範圍,以便整個新行適合。對於圖中的代碼如下:增加軸範圍

plot(spa8, ci.type="line", col="black", lwd=2, ci.lty=2, ci.col="black", 
ylab = "Species Richness", yaxp = c(0,60,6), xaxp = c(0,200,10), 
cex.axis = 0.75, frame.plot=FALSE, xvar = "individuals") + 
lines(spa7, ci.type="line", col="grey", lwd=2, ci.lty=2, ci.col="grey", 
xvar = "individuals")+ 
box(bty="L") 

我一直在使用usr()xaxp()嘗試,但沒有運氣,我也嘗試過使用axis()函數來設置自己的軸,但是這並沒有任何工作。我相信我一定在這裏做錯了,因爲它看起來應該很簡單!

有人可以幫我嗎?

感謝

回答

0

也許你可以玩的plot函數內xlimylim參數。例如,嘗試運行下面的代碼(逐行)並查看其差異。

## Default. 
plot(1:10) 

## Set x-axis to be between -10 and 10. 
plot(1:10, xlim = c(-10, 10)) 

## Set x-axis to be between -10 and 10, and y-axis to be between -5 and 5. 
plot(1:10, xlim = c(-10, 10), ylim = c(-5, 5)) 

希望幫助:)

+0

調整'xlim'和我'ylim'結果得到X和Y長度不同的錯誤。編輯:現在等待我已經重新啓動RStudio它的工作這一次。 – tom91