Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readjusting axes on plotly plot after filtering #129

Open
mm225022 opened this issue Jul 19, 2022 · 0 comments
Open

Readjusting axes on plotly plot after filtering #129

mm225022 opened this issue Jul 19, 2022 · 0 comments

Comments

@mm225022
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant