How to add partially-shaded error bars to dygraph plot

192 Views Asked by At

I am new to R software. My CSV data contain more than 10,000 units (rows) and two variables (columns). Data were recorded every twenty minutes (72 times per day) for six months using data logger. Here sample data and dygraph plotted using R.

dput(Preharvest)

tzone = "", tclass = c("POSIXct", "POSIXt")), .indexCLASS = c("POSIXct", 
"POSIXt"), tclass = c("POSIXct", "POSIXt"), .indexTZ = "", tzone = "", class = c("xts", 
"zoo"))

Names = c("Datetime", 
"Temp", "RH", "X"), class = "data.frame", row.names = c(NA, -5552L
))
Datetime          Temp    RH
2014-08-30 8:00   21.6    70.3
2014-08-30 8:20   21.7    69.8
2014-08-30 8:40   22.1    70.3
2014-08-30 9:00   22.5    70.8
2014-08-30 9:20   22.7    70.9
2014-08-30 9:40   23.3    71.5
2014-08-30 10:00  23.4    70.4
2014-08-30 10:20  23.8    71.3
2014-08-30 10:40  24.4    71.6
2014-08-30 11:00  25      71.7
2014-08-30 11:20  25.7    68.2
2014-08-30 11:40  25.8    63.8
2014-08-30 12:00  26.4    63.9
2014-08-30 12:20  27.5    65.1
2014-08-30 12:40  28.1    62.6
2014-08-30 13:00  28.4    61.1
2014-08-30 13:20  28.4    60.1
2014-08-30 13:40  28.2    59.3
2014-08-30 14:00  28      58.3
2014-08-30 14:20  27.6    56.9
2014-08-30 14:40  27.4    57.1
2014-08-30 15:00  27.3    57.3
2014-08-30 15:20  27.4    57.5
2014-08-30 15:40  27.4    57.4
2014-08-30 16:00  27.5    57.2
2014-08-30 16:20  27.6    57.2
2014-08-30 16:40  27.6    57
2014-08-30 17:00  27.5    55.8
2014-08-30 17:20  27.4    55.8
2014-08-30 17:40  27.3    55.4
2014-08-30 18:00  27.2    55.8
2014-08-30 18:20  27.1    55.8
2014-08-30 18:40  27      55.8
2014-08-30 19:00  26.8    55.4
2014-08-30 19:20  26.6    55.6
2014-08-30 19:40  26.5    55.3
2014-08-30 20:00  26.1    54.7
2014-08-30 20:20  25.8    54.5
2014-08-30 20:40  25.5    55.3
2014-08-30 21:00  25.4    55.6
2014-08-30 21:20  25.4    55.9
2014-08-30 21:40  25.4    56.1
2014-08-30 22:00  25.4    56.1
2014-08-30 22:20  24.8    55.9
2014-08-30 22:40  24.3    56.6
2014-08-30 23:00  23.8    57.4
2014-08-30 23:20  23.5    58
2014-08-30 23:40  23.1    58.6
2014-08-31 0:00   22.9    59.2
2014-08-31 0:20   22.6    59.8
2014-08-31 0:40   22.4    60.3
2014-08-31 1:00   22.3    60.8
2014-08-31 1:20   22.1    61.3
2014-08-31 1:40   22  61.7
2014-08-31 2:00   21.8    62.2
2014-08-31 2:20   21.7    62.6
2014-08-31 2:40   21.6    63
2014-08-31 3:00   21.6    63.4
2014-08-31 3:20   21.5    63.7
2014-08-31 3:40   21.4    64
2014-08-31 4:00   21.4    64.4
2014-08-31 4:20   21.3    64.7
2014-08-31 4:40   21.2    65
2014-08-31 5:00   21.2    65.2
2014-08-31 5:20   21.1    65.5
2014-08-31 5:40   21.1    65.8
2014-08-31 6:00   21.1    65.9
2014-08-31 6:20   21      66.2
2014-08-31 6:40   21      66.4
2014-08-31 7:00   21.1    67.3
2014-08-31 7:20   21.2    68.1
2014-08-31 7:40   21.6    67.6
2014-08-31 8:00   21.7    67.9
2014-08-31 8:20   22.1    68.9
2014-08-31 8:40   22.1    67.7
2014-08-31 9:00   22.1    68
2014-08-31 9:20   22.7    70.4
2014-08-31 9:40   24.9    70.6
2014-08-31 10:00  26.2    62.3
2014-08-31 10:20  26.8    62.4
2014-08-31 10:40  27.6    62.4
2014-08-31 11:00  27.8    60.3
2014-08-31 11:20  27.7    58.1
2014-08-31 11:40  27.2    56.4
2014-08-31 12:00  28.8    51.6
2014-08-31 12:20  27.5    54.8
2014-08-31 12:40  27.2    55.6
2014-08-31 13:00  27.9    58.5
2014-08-31 13:20  27.3    58.6
2014-08-31 13:40  27.2    58.4
2014-08-31 14:00  27      59
2014-08-31 14:20  26.7    59.3
2014-08-31 14:40  26.8    59.4
2014-08-31 15:00  26.2    58.2
2014-08-31 15:20  25.6    58.3
2014-08-31 15:40  26      59.6
2014-08-31 16:00  26.8    61.5
2014-08-31 16:20  27.6    61.8
2014-08-31 16:40  27.8    61.2
2014-08-31 17:00  27.7    59.2
2014-08-31 17:20  28.1    59.3
2014-08-31 17:40  28.5    58.4
2014-08-31 18:00  28.5    57.7
2014-08-31 18:20  28.9    57.3
2014-08-31 18:40  29.3    53.3
2014-08-31 19:00  28.6    51.5
2014-08-31 19:20  27.8    51.2
2014-08-31 19:40  27.1    51.5
2014-08-31 20:00  26.6    51.9
2014-08-31 20:20  26.3    53.2
2014-08-31 20:40  25.7    55.2
2014-08-31 21:00  25.2    68.1
2014-08-31 21:20  26      58.1
2014-08-31 21:40  25      58.3
2014-08-31 22:00  24.5    59.1
2014-08-31 22:20  23.8    59.2
2014-08-31 22:40  23.3    59.7
2014-08-31 23:00  22.9    60.3
2014-08-31 23:20  22.6    61.1
2014-08-31 23:40  22.5    61.5
2014-09-01 0:00   22.4    61.9
2014-09-01 0:20   22.3    62.2
2014-09-01 0:40   22.3    62.6
2014-09-01 1:00   22.2    62.9
2014-09-01 1:20   22.2    63.1
2014-09-01 1:40   22.1    63.4
2014-09-01 2:00   22.2    63.8
2014-09-01 2:20   22.2    64.1
2014-09-01 2:40   22.2    64.4
2014-09-01 3:00   22.1    64.7
2014-09-01 3:20   22.1    65
2014-09-01 3:40   22.1    65.4
Preharvest<- read.csv("C:/Users/User/Desktop/Preharvest.csv")
Preharvest1<- as.data.frame(Preharvest  , header=True)
library(dygraphs)
library(xts)
s <-xts(Preharvest1[, 2:3], order.by=as.POSIXct(Preharvest1$Datetime))  
dygraph(s)

Sample dygraph

However, I would like to have dygraph with error bars of partial shade with time series. Here sample dygraph was taken from internet that I would like to have.

enter image description here

Is there anyone help me and guide to have dygraph with error bars based on a daily mean of the data with partial shade?

0

There are 0 best solutions below