2016-11-24 18 views
1

我試圖繪製流量歷時曲線與包hydroTSM,使用fdcu.matrix功能。不幸的是,我無法設法增加或減少y軸長度。我嘗試了ylim = c(lownumber,highnumber)fdcu ylim不積包工作:hydroTSM - logaritmic y軸

當這沒有工作,我試圖複製粘貼包在R,以便我可以運行它作爲一個函數,並調整它...但fdcu.matrix不幸的是不運行沒有要求( hydroTSM)

(可在https://github.com/cran/hydroTSM/blob/master/R/fdcu.R

我怎樣才能手動或自動調整ylim到datarange ..?

這是我的數據矩陣的一部分:

dput(m.fdc01 [1:20,1:5])

結構(C(1,2,3,4,5 ,6,7,8,9,10,11,12,13,14,15, 16,17,18,19,20,6.45,6.45,6.45,6.45,6.372,6.372,6.529, 7.09,3.8 ,8.015,8.277,9.361,10.41,10.705,9.548,8.811,0.9.176,8.631,8.542,8.365,8.189,8.102,7.588,7.42,7.254, 7.09,7.008,6.927,6.847,6.767,6.687,6.687,6.687 ,6.687,0.6.847,6.927,1.008,6.927,7.09,7.758,8.277,7 929,7.843, 7.673,7.588,7.588,7.588,7.588,7.588,7.42,7.42,8.811, 9.927,8.631,8.189,7.673,7.42,7.254,7.008,7.008,17.397, NA,NA,NA, NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA ,16.782,15.82),.dim僞= C(20L,5L),.Dimnames =列表(NULL , C( 「DAYOFYEAR」, 「1970年」, 「1971年」, 「1972年」, 「1973年」)))

# Plot with multiple flow duration curves & legend: 

require(hydroTSM) 
fdcu.matrix(m.fdc01[,-1], lband=m.fdc01[,-1], uband=m.fdc01[,-1], sim=m.fdc[,-1], plot=TRUE, 
     main ="FDC station 1LA04:1970-1978", xlab="% Time flow equalled or exceeded", 
     ylab="Q, [m3/s]", ylim=c(1,50),yat=c(0.01,0.02,0.05, 0.1,0.2,0.5, 1,2,5,10,20,50,100), 
     bands.col = "white", col=col_matsel, lwd=mat_lwd,leg.txt="", 
     leg.cex=0.5,leg.pos="auto",cex.axis=1,thr.shw=FALSE) 
legend("bottomleft",legendtextsel,col=col_matsel, lwd=4, y.intersp=1,bty="n",cex=1) 

enter image description here

回答

1

我覺得這是一個錯誤。我會建議你聯繫開發人員。當fdcu.matrix()的算法使用fdcu()fdcu.matrix()不給的ylim的信息fdcu()。您可以通過複製原始代碼並僅刪除一個術語來輕鬆修改fdcu.matrix()

製備
運行fdcu.matrix和複製輸出(即,原始的代碼)。

讓你的函數(幾乎所有被粘貼)
fdcu.matrix2 <- ""paste""和刪除的說法,ylim

參考
fdcu.matrix2 <- 
function (x, lband, uband, sim, lQ.thr = 0.7, hQ.thr = 0.2, plot = TRUE, 
    log = "y", main = "Flow Duration Curve", xlab = "% Time flow equalled or exceeded", 
    ylab = "Q, [m3/s]", ylim, yat = c(0.01, 0.1, 1), xat = c(0.01, ... 
         ^^^^^ delete!! 
例如
require(hydroTSM) 

fdcu.matrix2(m.fdc01[,-1], lband=m.fdc01[,-1], uband=m.fdc01[,-1], sim=m.fdc01[,-1], 
     plot=TRUE, main ="fdcu.matrix2_test", xlab="xlab", ylab="Q, [m3/s]", 
     ylim=c(1,50), yat=c(0.01,0.02,0.05, 0.1,0.2,0.5, 1,2,5,10,20,50), 
     bands.col="white", leg.txt="", leg.cex=0.5, leg.pos="auto", 
     cex.axis=0.7, thr.shw=FALSE) 

    # [note] yat and pretty(ylim) are ylabels 

    # [note2 (edited)] 
    # when log = "y", ylim[1] is disregarded and 0.01 is used instead of it. 

enter image description here