Readjusting axes on plotly plot after filtering
mm225022 opened this issue · comments
This is the same in concept to issue #107, however, that issue was for leaflet and my request is for a plotly plot.
Essentially, I have a large plot with a lot of data. I wanted to use filter_slider
to be able to zoom in on a portion of the data; however, what ends up happening is just that the data that is filtered out is removed from the plot, but the axes themselves do not change.
I created a reproducible example below from the mtcars
dataset:
library(crosstalk)
library(plotly)
library(ggplot2)
library(dplyr)
shared_mtcars <- SharedData$new(mtcars)
tt<-shared_mtcars %>%
ggplot(aes(x=mpg, y=hp))+
geom_point(size=2)+
theme_bw()+
scale_x_continuous(limits=c(min(shared_mtcars$data()$mpg), max(shared_mtcars$data()$mpg)))
bscols(widths = 10,
list(
filter_slider("mpg", "MPG", shared_mtcars, ~mpg)
),
ggplotly(tt)
)
As you can see, I attempted to adjust the limits on my graph based on the shared_mtcars
SharedData, but it still didn't adjust the graph.
In addition to attempting to adjust within scale_x_continuous(...)
, I also tried coord_cartesian(xlim=...)
but got the same result.
If this functionality could be added, I believe it would be very beneficial.