Learn R Programming

plotly (version 4.10.3)

rangeslider: Add a range slider to the x-axis

Description

Add a range slider to the x-axis

Usage

rangeslider(p, start = NULL, end = NULL, ...)

Arguments

p

plotly object.

start

a start date/value.

end

an end date/value.

...

these arguments are documented here https://plotly.com/r/reference/#layout-xaxis-rangeslider

Author

Carson Sievert

Examples

Run this code

plot_ly(x = time(USAccDeaths), y = USAccDeaths) %>% 
  add_lines() %>%
  rangeslider()
  
d <- tibble::tibble(
  time = seq(as.Date("2016-01-01"), as.Date("2016-08-31"), by = "days"),
  y = rnorm(seq_along(time))
 )
 
plot_ly(d, x = ~time, y = ~y) %>%
  add_lines() %>%
  rangeslider(d$time[5], d$time[50])
  

Run the code above in your browser using DataLab