Skip to content

r ggplotly implementation of ggmap #649

Closed
@AmyMikhail

Description

@AmyMikhail

I map coordinates using ggmap to put a google map in the background and plot basic points on top of it. It would be nice to be able to identify the points on the map with a label of my choosing, using ggplotly. However, it appears this is not yet implemented.

I have R 3.3.0 and am using ggmap_2.6.1 and plotly plotly_3.4.13 in RStudio 0.99.489.

Running the following on coordinates and descriptive variables from the data.table called linelist:
`# Create a boundary box to zoom manually
bbox <- ggmap::make_bbox(lon, lat, linelist, f = 0.85)

Get a map centred on the boundary box

map_loc <- get_map(location = bbox, source = 'google', maptype = "roadmap", crop = FALSE, color = "bw")

Plot the map in the background

map <- ggmap(map_loc, extent = 'device', maprange = FALSE)

Add the points for each postcode, here I've used case definition and given them different colours

map <- map + geom_point(data = linelist, aes(x = lon, y = lat, fill = casedef), colour = "black", pch = 21, size = 3) +
scale_fill_manual(values = c("blue", "red")) +
labs(fill = "SNP address") +
scale_size(guide = "none")
map2 <- ggplotly()`

Gives this message:
Warning message: In geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]) : geom_GeomRasterAnn() has yet to be implemented in plotly. If you'd like to see this geom implemented, Please open an issue with your example code at https://github.com/ropensci/plotly/issues

When I look at map2 I can see the points and there is a label if I hover over them, but they are joined by lines and there is no map in the background.

It would be great if this feature could be added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions