Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dyShading

dygraph region shading


Description

Specify that a region of a dygraph be drawn with a background shading

Usage

dyShading(dygraph, from, to, color = "#EFEFEF", axis = "x")

Arguments

dygraph

Dygraph to add shading to

from

Date/time or numeric to shade from (for date/time this must be a as.POSIXct object or another object convertible via as.POSIXct).

to

Date/time or numeric to shade to (for date/time this must be a as.POSIXct object or another object convertible via as.POSIXct).

color

Color of shading. This can be of the form "#AABBCC" or "rgb(255,100,200)" or "yellow". Defaults to a very light gray.

axis

Axis to apply shading. Choices are "x" or "y".

Value

A dygraph with the specified shading

Note

See the online documentation for additional details and examples.

Examples

library(dygraphs)

dygraph(nhtemp, main = "New Haven Temperatures") %>% 
  dyShading(from = "1920-1-1", to = "1930-1-1") %>%
  dyShading(from = "1940-1-1", to = "1950-1-1")
  
dygraph(nhtemp, main = "New Haven Temperatures") %>% 
  dyShading(from = "48", to = "52", axis = "y") %>%
  dyShading(from = "50", to = "50.1", axis = "y", color = "black")

dygraphs

Interface to 'Dygraphs' Interactive Time Series Charting Library

v1.1.1.6
MIT + file LICENSE
Authors
Dan Vanderkam [aut, cph] (dygraphs library in htmlwidgets/lib, http://dygraphs.com/), Petr Shevtsov [cre, cph], JJ Allaire [aut], RStudio [cph], Jonathan Owen [aut, cph], Daniel Gromer [aut, cph], Benoit Thieurmel [aut, cph], Kent Laukhuf [ctb], jQuery Foundation [cph] (jQuery library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/htmlwidgets/lib/jquery/AUTHORS.txt)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.