Vertical and Horizontal shading

Vertical shading:

Dygraph can assign shading features on the timeline portion to analyze different time intervals. By using dyshading, we can assign time-interval corresponding to color for better analysis of the stock portion.

R




dygraph(price, main = "TSLA Stock price analysis") %>% 
     dySeries(label = "Temp (F)",
              color = "black") %>%
     dyShading(from = "2018-1-1",
               to = "2019-12-1"
               color = "#FFE6E6") %>%
     dyShading(from = "2020-1-1"
               to = "2021-1-1",
               color = "#CCEBD6")


Output:

 

Horizontal shading

Dygraphs provide horizontal shading by use of mean and standard deviations. We can assign intervals in dyshading and assign axis parameters to y. Here, ROC function is used to create ROC Curve. 

R




ret = ROC(TSLA[, 4])
mn = mean(ret, na.rm = TRUE) #mean
std = sd(ret, na.rm = TRUE) #standard deviation
dygraph(ret, main = "TSLA Share Price") %>% 
     dySeries("TSLA.Close", label = "TSLA") %>%
     dyShading(from = mn - std, to = mn + std, axis = "y")


Output:

Horizontal shade in grey colour

How to use interactive time series graph using dygraphs in R

Dygraphs refer to as Dynamic graphics which leads to an easy way to create interaction between user and graph. The dygraphs are mainly used for time-series analysis. The dygraphs package is an R interface to the dygraphs JavaScript charting library in R Programming Language

Similar Reads

Creating simple dygraphs

Let’s take stock data for a better understanding of time series....

Series color graph

...

Vertical and Horizontal shading

Dygraph can assign different color palettes to each visualization line. For example, our four-parameter in TSLA data (open, high, low, close) can be represented as different colors. Dygraph provides dyOptions() in which colors parameter can be useful to identify each stock line smoothly....

Candlestick graph

...

Upper/lower bar

Vertical shading:...

Range Selector

...

Contact Us