renderPlotly creates lines between points when combined with ggmap


#1

Hi,

In my shiny App, I need to plot a map of Paris, and some overlay points. To do this, I use ggmap package.

When I plot my map with points using renderPlot, all is fine:
output$demand <- renderPlot({ # generate bins based on input$bins from ui.R ggmap(map()) + geom_point(data=probe(),aes(x=XCenter,y=YCenter),alpha=0.2,size=1) })

but with renderPlotly, points are connected with lines.
output$demand <- renderPlotly({ # generate bins based on input$bins from ui.R ggmap(map()) + geom_point(data=probe(),aes(x=XCenter,y=YCenter),alpha=0.2,size=1) })

Any idea why ? I would like to benefit from renderPlotly interactivity.

I will try to add a perfectly reproducible example asap.

Thanks.


#2

You may want to take a look at the leaflet package as this allows for interactive maps and may be better suited for this than ggmap + ggplotly.


#3

Thanks. This is what I started to do. But still, I would like to understand if it is a bug, or if I missed something :).


#4

It's hard to say without a reprex (short for minimal reproducible example).

Right now the best way to install reprex is:

# install.packages("devtools")
devtools::install_github("tidyverse/reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

For pointers specific to the community site, check out the reprex FAQ, linked to below.