我想在dygraph上的数据系列周围显示错误条,例如此链接中的图像(http://www.webappers.com/2009/12/15/produce-interactive-charts-of-time-series-with-dygraphs/)。我使用以下r代码绘制了dygraph。
weather_final <- read.csv("C:/Users/User/Desktop/weather_data.csv")
weather_final1<- as.data.frame(weather_final , header=True)
library(dygraphs)
library(xts)
s <- xts(weather_final1[, 2:3 ], order.by=as.POSIXct(weather_final1$Datetime,"%Y/%m/%d %H:%M" ))
head(s)
dygraph(s)%>%
dyRoller(showRoller = TRUE,rollPeriod = 48)%>%
dyHighlight(highlightSeriesBackgroundAlpha = 2,
hideOnMouseOut = TRUE )%>%
dyRangeSelector(height = 40, strokeColor = "RED")%>%
dyAxis("y", label = "Temp (0C)", valueRange = c(10, 40) )%>%
dyAxis("y2", valueRange = c(10, 100)) %>%
dyAxis("y2", label = "RH (%)",independentTicks = TRUE) %>%
dySeries("RH", axis = 'y2')
这是输出dygraph
感谢您在两个系列中绘制错误栏的任何帮助!
下面是示例数据。数据每30分钟收集一次,为期六个月。
Datetime Temp RH
2014-12-25 0:00 19.5 49.8
2014-12-25 0:30 19.6 49.1
2014-12-25 1:00 20.1 46.1
2014-12-25 1:30 20.8 43.8
2014-12-25 2:00 21.5 44.7
2014-12-25 2:30 22.8 41.1
2014-12-25 3:00 23.7 39.2
2014-12-25 3:30 24.9 36.2
2014-12-25 4:00 25.5 34.6
2014-12-25 4:30 25.6 33.5
2014-12-25 5:00 25.6 33.7
2014-12-25 5:30 26.1 32.9
2014-12-25 6:00 26.3 32
2014-12-25 6:30 26.4 31.9
2014-12-25 7:00 26.8 31.4
2014-12-25 7:30 26.7 31.3
2014-12-25 8:00 26.2 31.8
2014-12-25 8:30 25.9 31.7
2014-12-25 9:00 25.3 35.6
2014-12-25 9:30 24.4 42.6
2014-12-25 10:00 24.1 45.7
2014-12-25 10:30 23.8 45.8
2014-12-25 11:00 23.3 42.3
2014-12-25 11:30 22.8 45.1
2014-12-25 12:00 22.5 47.4
2014-12-25 12:30 22 50
2014-12-25 13:00 22.1 51
2014-12-25 13:30 21.3 51.4
2014-12-25 14:00 21.4 52.6
2014-12-25 14:30 21.4 52.2
2014-12-25 15:00 21.4 55
2014-12-25 15:30 21.2 54.6
2014-12-25 16:00 20.9 54.5
2014-12-25 16:30 20.2 50.3
2014-12-25 17:00 19.9 52.9
2014-12-25 17:30 20 56.3
2014-12-25 18:00 19.9 56.3
2014-12-25 18:30 19.8 57.2
2014-12-25 19:00 19.8 57.5
2014-12-25 19:30 19.7 57.5
2014-12-25 20:00 19.3 56.8
2014-12-25 20:30 19.2 57.8
2014-12-25 21:00 18.9 58
2014-12-25 21:30 18.7 58.2
2014-12-25 22:00 18.5 58.6
2014-12-25 22:30 18.4 56.3
2014-12-25 23:00 18.3 54.8
2014-12-25 23:30 18.3 50.2
2014-12-26 0:00 18.3 50.2
2014-12-26 0:30 18.4 47.9
2014-12-26 1:00 18.9 46.9
2014-12-26 1:30 19.8 46.5
2014-12-26 2:00 20.8 44.5
2014-12-26 2:30 22.3 38.9
2014-12-26 3:00 23.1 38.5
2014-12-26 3:30 24.1 36.2
2014-12-26 4:00 24.7 35.3
2014-12-26 4:30 25.4 34
2014-12-26 5:00 25.2 33.5
2014-12-26 5:30 25.7 31.3
2014-12-26 6:00 25.8 32.7
2014-12-26 6:30 26.1 32
2014-12-26 7:00 25.7 28.9
2014-12-26 7:30 25.7 27.6
2014-12-26 8:00 25.4 29.2
2014-12-26 8:30 25.2 29.8
2014-12-26 9:00 24.5 34.9
2014-12-26 9:30 23.6 39
2014-12-26 10:00 22.7 42.1
2014-12-26 10:30 22.2 43
2014-12-26 11:00 22 44.1
2014-12-26 11:30 22.1 46.7
2014-12-26 12:00 21.7 45.5
2014-12-26 12:30 21.2 48.1
2014-12-26 13:00 21.2 50.4
2014-12-26 13:30 20.8 49.6
2014-12-26 14:00 20.5 49.2
2014-12-26 14:30 20.1 45.1
2014-12-26 15:00 20.2 50.2
2014-12-26 15:30 20.1 52.8
2014-12-26 16:00 19.9 51.9
2014-12-26 16:30 19.7 50.7
2014-12-26 17:00 19.5 51.8
2014-12-26 17:30 19.5 54.3
2014-12-26 18:00 19.1 54.1
2014-12-26 18:30 18.6 55.9
2014-12-26 19:00 18.8 55.6
2014-12-26 19:30 18.6 56.3
2014-12-26 20:00 18.5 56.3
2014-12-26 20:30 18.3 56.4
2014-12-26 21:00 18.1 56.6
2014-12-26 21:30 17.8 55.8
2014-12-26 22:00 17.8 56.3
2014-12-26 22:30 17.6 56.4
2014-12-26 23:00 17.4 52.4
2014-12-26 23:30 17.4 51.2
答案 0 :(得分:0)
您还没有提供可重现的示例,所以这是一个基本示例,使用内置数据从vignette改编而来:
# Data and fake confidence intervals
set.seed(5)
dat = cbind(ldeaths,
lwr=ldeaths - rnorm(length(ldeaths), 500, 20),
upr=ldeaths + rnorm(length(ldeaths), 500, 20))
dygraph(dat) %>%
dySeries(c("lwr","ldeaths","upr"))