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

Mouseover coordinates in plot area are wrong when coord_fixed of ggplot is set #1121

Closed
patrickroocks opened this issue Feb 27, 2016 · 0 comments · Fixed by #1525
Closed
Assignees

Comments

@patrickroocks
Copy link

patrickroocks commented Feb 27, 2016

The hoverOpts options of a plot area seems to provides wrong mouse coordinates, if a ggplot object is contained in the plot area using the option coord_fixed.

Here is a minimal example:

library(shiny)
library(ggplot2)

ui <- fluidPage(
  plotOutput("plot1", height = "300px", width = "100%",
             hover = hoverOpts(id = "plot_hover")),
  verbatimTextOutput("hover_info")
)

server <- function(input, output) {

  output$plot1 <- renderPlot({
    ggplot(mtcars, aes(x=mpg,y=qsec)) + geom_point() + 
      coord_fixed(xlim=c(0,30),ylim=c(0,30))
  })

  output$hover_info <- renderPrint({
    if(!is.null(input$plot_hover))
      paste0(input$plot_hover$x, " ", input$plot_hover$y)
    })
}

shinyApp(ui, server)`

When having a wide browser window (such that coord_fixed causes space in the left and in the right of the plot object) and positioning the mouse pointer near to the origin we get too high values for the x-value. It seems that coord_fixed is ignored by hoverOpts.

I already posted this on SO, where you also see a screenshot illustrating the problem:

http://stackoverflow.com/questions/35659823/mouseover-coordinates-in-ggplot-shiny-are-wrong-when-coord-fixed-is-set

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

Successfully merging a pull request may close this issue.

2 participants