Quick note: I have also posted this question on the R Studio Community.
I am trying to modify a plotly slider to make it a rangeslider similar to the one here: .
The problem with the rangeslider()
function is that instead of a rangeslider like the one in the image it produces one that is essentially a subplot of the main plot:
dat<- data.frame(y=rnorm(366, mean=100, sd=50),
x=seq(as.Date("2020-01-01"), as.Date("2020-12-31"), by="days"))
p1<- dat %>%
ggplot(aes(x=x, y=y)) +
geom_col() +
theme_minimal() +
xlab("") + ylab("")
ggplotly(p1, tooltip="x", dynamicTicks = TRUE) %>% rangeslider()
I have managed to get a slider more similar to the one I want in style using frame =
in ggplot's aesthetics, however the resulting slider only selects one value at a time instead of a range of them:
dat<- data.frame(y=rnorm(366, mean=100, sd=50),
x=seq(as.Date("2020-01-01"), as.Date("2020-12-31"), by="days"))
p1<- dat %>%
ggplot(aes(x=x, y=y, frame=as.character(x))) +
geom_col(position="dodge2") +
theme_minimal() +
xlab("") + ylab("")
ggplotly(p1, tooltip="x")
Is it possible to create a rangeslider in the style I want with plotly?. I would be hugely thankful for any advice on how to solve this issue.