-
Notifications
You must be signed in to change notification settings - Fork 2.1k
summarize_layout
does not return final range values
#2895
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
Comments
Thanks for the report. This is a tricky issue. I doubt we can fully resolve this in the near term, but let's see if we can make some progress. First, I'm not sure ggplot2 3.0.0 works as expected. Please try the following example:
Second, the problem fundamentally is that nobody actually knows what Third, A possible fix, which #2821 does not currently provide but could be expanded into, is to have both a function |
@clauswilke FWIW, |
@jcheng5 Ok. It doesn't seem to work with In any case, I think the fix I proposed above should work for now. I'll prepare a PR within the next few days, so we can try it. library(sf)
nc <- sf::st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
library(ggplot2)
library(shiny)
ui <- fluidPage(plotOutput("plot", brush = "brush"), tableOutput("table"))
server <- function(input, output, session) {
output$plot <- renderPlot({
ggplot(nc) +
stat_sf_coordinates() + coord_sf()
})
output$table <- renderTable({
brushedPoints(mtcars, input$brush)
})
}
shinyApp(ui, server) |
@jcheng5 One more question: Could you explain how brushing currently works? How do you go from the ranges of the layout summary to the original data? |
Brushing has always had some issues refer to rstudio/shiny#1433 even without transformation the example show a problem with discrete scales. |
I have updated #2821 so that Here is the example from @schloerke: library(ggplot2);
dat <- data.frame(xvar = c(10^-1, 10^3), yvar = c(2^-2, 2^4))
p <- ggplot(dat, aes(xvar, yvar)) + geom_point() +
scale_x_log10(expand = c(0 ,0)) +
scale_y_continuous(expand = c(0, 0)) +
coord_trans(y = "log2")
p ggplot2::summarise_layout(ggplot2::ggplot_build(p))
#> # A tibble: 1 x 10
#> panel row col vars xmin xmax ymin ymax xscale yscale
#> <fct> <dbl> <dbl> <list> <dbl> <dbl> <dbl> <dbl> <list> <list>
#> 1 1 1. 1. <list [0]> -1. 3. -2. 4. <S3: Sca… <S3: Sca… Created on 2018-09-17 by the reprex package (v0.2.0). |
summarize_layout
does not returning final range valuessummarize_layout
does not return final range values
@clauswilke #2821 works for my small litmus tests. I see the range function added back to coord-trans, so I don't expect any more range errors. Thank you for the documentation in summarize_layout and for (down the road) solidifying what |
@hadley This issue is blocking the release of 3.0.1. I see only two feasible ways forward:
My own preference is option 2. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Uh oh!
There was an error while loading. Please reload this page.
@clauswilke
Brushing points within shiny apps depends on the output of
ggplot2::summarise_layout(p)
CRAN ggplot2 3.0.0 works as expected.With changes from #2832 , the range values of
CoordTrans
where changed to map back to their original values. While I agree with the intent, ggplot2::summarise_layout uses the range values to calculate the returned domain value.With v3.0.0 the fully transformed scale values provide:
With current github version the fully transformed scale values provide:
The
ymin
andymax
are displaying the original values, not the fully transformed values.Shiny demo... Try selecting the two points at
x = 150
. In the dev version, select the very bottom of the plot (aroundy = 2
) are atx = 150
to brush the transformed data locations.@wch @jcheng5
The text was updated successfully, but these errors were encountered: