Skip to content

Commit f16879f

Browse files
committed
new argument 'thr.pos'
1 parent aa468a6 commit f16879f

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
NEWS/ChangeLog for hydroTSM
22

33
--------------------------
4-
# Changes in version 0.7-5 Ongoing
4+
# Changes in version 0.8-0 Ongoing
55

66
## New functions
77
o 'isComplete' : for testing for identifying whether a zoo object has a regular time frequency without missing values from the first one to the last one
@@ -17,6 +17,7 @@ NEWS/ChangeLog for hydroTSM
1717
By default 1 (Jan)
1818
o 'cmv' : -) new argument 'start.month' to choose the starting month to be used in the computation of annual values.
1919
By default 1 (Jan)
20+
o 'fdc' : -) new arguments: 'thr.pos'
2021

2122
## Bug fixes
2223
o 'izoo2rzoo' : -) argument 'tz' is now able to correctly handle sub-daily zoo objects, with or without specification of a value by the user.

R/fdc.R

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# File fdc.R
22
# Part of the hydroTSM R package, https://github.com/hzambran/hydroTSM ;
33
# https://CRAN.R-project.org/package=hydroTSM/
4-
# Copyright 2007-2017 Mauricio Zambrano-Bigiarini
4+
# Copyright 2007-2025 Mauricio Zambrano-Bigiarini
55
# Distributed under GPL 2 or later
66

77
################################################################################
@@ -14,6 +14,7 @@
1414
# 05-Aug-2013 #
1515
# 15-Jan-2014 #
1616
# 04-Feb-2015 #
17+
# 27-Dec-2025 #
1718
################################################################################
1819

1920
# Plot the flow Duration Curve in the original time units of 'x' and
@@ -48,6 +49,7 @@ fdc.default <- function (x,
4849
leg.txt=NULL,
4950
leg.cex=1,
5051
leg.pos="topright",
52+
thr.pos="bottomleft",
5153
verbose= TRUE,
5254
thr.shw=TRUE,
5355
new=TRUE,
@@ -154,8 +156,8 @@ fdc.default <- function (x,
154156
x.lQ <- x[Qposition(dc.plot, lQ.thr)]
155157
x.hQ <- x[Qposition(dc.plot, hQ.thr)]
156158

157-
legend("bottomleft", c(paste("Qhigh.thr=", round(x.hQ, 2), sep=""),
158-
paste("Qlow.thr=", round(x.lQ, 2), sep="") ),
159+
legend(x=thr.pos, c(paste("Qhigh.thr=", round(x.hQ, 2), sep=""),
160+
paste("Qlow.thr=", round(x.lQ, 2), sep="") ),
159161
cex=0.8, bty="n") #bty="n" => no box around the legend
160162
} # IF end
161163
} # IF end
@@ -177,6 +179,7 @@ fdc.default <- function (x,
177179
# Updates: 16-Sep-2011 ; 03-Nov-2011 #
178180
# 02-May-2012 #
179181
# 05-Aug-2013 #
182+
# 27-Dec-2025 #
180183
################################################################################
181184

182185
fdc.matrix <- function (x,
@@ -200,6 +203,7 @@ fdc.matrix <- function (x,
200203
leg.txt=NULL,
201204
leg.cex=1,
202205
leg.pos="topright",
206+
thr.pos="bottomleft",
203207
verbose=TRUE,
204208
thr.shw=TRUE,
205209
new=TRUE,
@@ -279,6 +283,7 @@ fdc.matrix <- function (x,
279283
# Updates: 03-Nov-2011 #
280284
# 02-May-2012 #
281285
# 05-Aug-2013 #
286+
# 27-Dec-2025 #
282287
################################################################################
283288
fdc.data.frame <- function(x,
284289
lQ.thr=0.7,
@@ -301,6 +306,7 @@ fdc.data.frame <- function(x,
301306
leg.txt=NULL,
302307
leg.cex=1,
303308
leg.pos="topright",
309+
thr.pos="bottomleft",
304310
verbose=TRUE,
305311
thr.shw=TRUE,
306312
new=TRUE,
@@ -332,6 +338,7 @@ fdc.data.frame <- function(x,
332338
leg.txt=leg.txt,
333339
leg.cex=leg.cex,
334340
leg.pos=leg.pos,
341+
thr.pos=thr.pos,
335342
thr.shw=thr.shw,
336343
new=new,
337344
...)
@@ -347,6 +354,7 @@ fdc.data.frame <- function(x,
347354
# Started: 03-Nov-2011 #
348355
# Updates: 02-May-2012 #
349356
# 05-Aug-2013 #
357+
# 27-Dec-2025 #
350358
################################################################################
351359
fdc.zoo <- function (x,
352360
lQ.thr=0.7,
@@ -369,6 +377,7 @@ fdc.zoo <- function (x,
369377
leg.txt=NULL,
370378
leg.cex=1,
371379
leg.pos="topright",
380+
thr.pos="bottomleft",
372381
verbose=TRUE,
373382
thr.shw=TRUE,
374383
new=TRUE,
@@ -398,6 +407,7 @@ fdc.zoo <- function (x,
398407
leg.txt= leg.txt,
399408
leg.cex=leg.cex,
400409
leg.pos=leg.pos,
410+
thr.pos=thr.pos,
401411
thr.shw=thr.shw,
402412
new=new,
403413
...)
@@ -423,6 +433,7 @@ fdc.zoo <- function (x,
423433
leg.txt=leg.txt,
424434
leg.cex=leg.cex,
425435
leg.pos=leg.pos,
436+
thr.pos=thr.pos,
426437
thr.shw=thr.shw,
427438
new=new,
428439
...)

man/fdc.Rd

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,32 @@ fdc(x, ...)
2525
main="Flow Duration Curve", xlab="\% Time flow equalled or exceeded",
2626
ylab="Q, [m3/s]", ylim, yat=c(0.01, 0.1, 1), xat=c(0.01, 0.025, 0.05), col="black",
2727
pch=1, lwd=1, lty=1, cex=0.4, cex.axis=1.2, cex.lab=1.2, leg.txt=NULL, leg.cex=1,
28-
leg.pos="topright", verbose= TRUE, thr.shw=TRUE, new=TRUE, ...)
28+
leg.pos="topright", thr.pos="bottomleft",
29+
verbose= TRUE, thr.shw=TRUE, new=TRUE, ...)
2930

3031
\method{fdc}{matrix}(x, lQ.thr=0.7, hQ.thr=0.2, plot=TRUE, log="y",
3132
main= "Flow Duration Curve", xlab="\% Time flow equalled or exceeded",
3233
ylab="Q, [m3/s]", ylim, yat=c(0.01, 0.1, 1), xat=c(0.01, 0.025, 0.05),
3334
col=palette("default")[1:ncol(x)], pch=1:ncol(x), lwd=rep(1, ncol(x)),
3435
lty=1:ncol(x), cex=0.4, cex.axis=1.2, cex.lab=1.2, leg.txt=NULL,
35-
leg.cex=1, leg.pos="topright",verbose=TRUE, thr.shw=TRUE, new=TRUE, ...)
36+
leg.cex=1, leg.pos="topright", thr.pos="bottomleft",
37+
verbose=TRUE, thr.shw=TRUE, new=TRUE, ...)
3638

3739
\method{fdc}{data.frame}(x, lQ.thr=0.7, hQ.thr=0.2, plot=TRUE, log="y",
3840
main= "Flow Duration Curve", xlab="\% Time flow equalled or exceeded",
3941
ylab="Q, [m3/s]", ylim, yat=c(0.01, 0.1, 1), xat=c(0.01, 0.025, 0.05),
4042
col=palette("default")[1:ncol(x)], pch=1:ncol(x), lwd=rep(1, ncol(x)),
4143
lty=1:ncol(x), cex=0.4, cex.axis=1.2, cex.lab=1.2, leg.txt=NULL,
42-
leg.cex=1, leg.pos="topright", verbose=TRUE, thr.shw=TRUE, new=TRUE, ...)
44+
leg.cex=1, leg.pos="topright", thr.pos="bottomleft",
45+
verbose=TRUE, thr.shw=TRUE, new=TRUE, ...)
4346

4447
\method{fdc}{zoo}(x, lQ.thr=0.7, hQ.thr=0.2, plot=TRUE, log="y",
4548
main= "Flow Duration Curve", xlab="\% Time flow equalled or exceeded",
4649
ylab="Q, [m3/s]", ylim, yat=c(0.01, 0.1, 1), xat=c(0.01, 0.025, 0.05),
4750
col=palette("default")[1:NCOL(x)], pch=1:NCOL(x), lwd=rep(1, NCOL(x)),
4851
lty=1:NCOL(x), cex=0.4, cex.axis=1.2, cex.lab=1.2, leg.txt=NULL,
49-
leg.cex=1, leg.pos="topright", verbose=TRUE, thr.shw=TRUE, new=TRUE, ...)
52+
leg.cex=1, leg.pos="topright", thr.pos="bottomleft",
53+
verbose=TRUE, thr.shw=TRUE, new=TRUE, ...)
5054

5155
}
5256
%- maybe also 'usage' for other objects documented here.
@@ -117,6 +121,10 @@ numeric, indicating the character expansion factor for the legend, *relative* to
117121
}
118122
\item{leg.pos}{
119123
keyword to be used to position the legend. One of the list \sQuote{"bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", "center"}. This places the legend on the inside of the plot frame at the given location. See \code{\link[graphics]{legend}}.
124+
}
125+
\item{thr.pos}{
126+
keyword to be used to position the streamflow values corresponding to the user-defined thresholds \code{lQ.thr} and \code{hQ.thr}. It is only used when \code{thr.shw=TRUE}. \cr
127+
One of the list \sQuote{"bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", "center"}. This places the the streamflow values on the inside of the plot frame at the given location. See \code{\link[graphics]{legend}}.
120128
}
121129
\item{verbose}{
122130
logical; if TRUE, progress messages are printed (when \code{x} is a matrix or data.frame).

0 commit comments

Comments
 (0)