Óscar Jiménez oscar.jimenez.fdez at gmail.com
Thu May 26 17:57:27 CEST 2016

```Thanks for your answers

I'm going to share my script and my database in an excel file, where you
can check the kind of graph I would like to make (see attached document,
you can find it in Sheet1. Sheet 3 is the one that I used in .csv format to
work with in R).

Script:

# HYDROGRAPH SEPARATION ANALYSIS FOR EVENTS: JULY 9TH AND SEPT 11TH

# Event 20. July 9th, 2015

dir()

# Ev20HS: P event 20. Hydrograph separation
as.data.frame(Ev20HP)
colnames(Ev20HS)<- c("Date","Hour","P", "Qt", "St2H", "P2H", "GW2H",
"St18O", "P18O", "GW18O",
"Qold2H", "Qnew2H", "%old2H", "%new2H", "Qold18O",
"Qnew18O", "%old18O", "%new18O")
paste(Ev20HS\$Date, Ev20HS\$Hour)
Ev20HS\$date.time <- paste(Ev20HS\$Date, Ev20HS\$Hour)
as.POSIXct(Ev20HS\$date.time, format="%Y/%m/%d %H:%M:%S", tz="-7")
Ev20HS\$date.time <- as.POSIXct(Ev20HS\$date.time, format="%Y/%m/%d
%H:%M:%S", tz="-7")

par(mar=c(4, 4, 4, 4))
plot(Ev20HS\$date.time, Ev20HS\$P, type="h", axes= FALSE, col="cadetblue4",
ylim=c(10,0),
lwd=2, xlab= "Hour", xline= 1.5, ylab = " ")
axis (4, lwd= 1)
mtext (4, line=2, text="P (mm)")
par(new=T)
plot(Ev20HS\$date.time, Ev20HS\$Qt, type="l", col="deepskyblue", lwd=2,
ylim=c(0,0.02), xlab= " ", ylab = " ")
axis (2, lwd= 1)
mtext (2, line=2.25, text="Q (mm/10min)")
par(new=T)
plot(Ev20HS\$date.time, Ev20HS\$Qold2H, type="l", axes= FALSE, col="sienna3",
lwd=2, ylim=c(0,0.02), xlab= " ", ylab = " ")
cord.x <- c(7, 7, 13, 13)
cord.y <- c(0.00223742, 0.00238599, 0.01043445, 0.00970288)
polygon(cord.x, cord.y, col="steelblue3")

I want to plot in the same graph:

a) Precipitation (P) as a barplot (downwards) --> DONE
b) Total discharge in Stream (Qt) --> DONE
c) Discharge of groundwater, i.e. old component (Qold2H) --> The space
between Qt and Qold2H needs to be shaded with one colour, and the space
between Qold2H and x-axes needs to be shaded as well.

Another question, is there any option to make these curves smoother? I
don't really like those ugly peaks.

On 26 May 2016 at 17:21, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:

> On 26/05/2016 11:20 AM, Óscar Jiménez wrote:
>
>> oops, sorry I didn't know that... I'll answer in R-help. It was the 1st
>> time I was using this tool.
>>
>> Also, I never learned programming and R... so I do not control theses
>> languages. I'm just trying to work with it and got no support, and so many
>> questions arises.. hahaha
>>
>
> Don't worry about it.  I was just giving advice for the future.
>
> Duncan Murdoch
>
>
>
>> On 26 May 2016 at 17:12, Duncan Murdoch <murdoch.duncan at gmail.com
>> <mailto:murdoch.duncan at gmail.com>> wrote:
>>
>>     On 26/05/2016 11:03 AM, Óscar Jiménez wrote:
>>
>>         Hi Duncan,
>>
>>         Thanks for the quick reply  :)
>>         Does the function Sys.Date return a time series (created with
>>         the function POSIXct), with numerical values?
>>
>>
>>     It returns a Date object.  The str() function will show you that.
>>     But Date, POSIXct, and even POSIXlt are supported by many of the
>>     graphics functions, so you don't need to worry about the conversions.
>>
>>         I mean... I think the best option is to convert the time
>>         series (plotted as characters), into numerical values, right?
>>
>>
>>     No, that is not needed.
>>
>>         Or is there any other function that allows me to draw the
>>         shade under the curve using time series as the "x" variable?
>>
>>
>>     polygon() does.
>>
>>     You should try things; R won't break.
>>
>>
>>         If you need more info I can share my script and my database
>>         and you can see it properly.
>>
>>
>>     You should always do that when you pose your question; you should
>>     also send your questions to R-help, not privately. I've cc'd my
>>     response there.
>>
>>     Duncan Murdoch
>>
>>
>>
>
```