if (interactive()) {
# only run for interactive sessions
df <- expand.grid(x = 0:-5, y = 0:-5)
ggplot(df, aes(x, y)) + geom_point() +
annotate(geom = "point", x = -2, y = -2, colour = "red")
(pt <- gglocator(mercator = FALSE)) # click red point
last_plot() +
annotate("point", pt$x, pt$y, color = "blue", size = 3, alpha = .5)
hdf <- get_map("houston, texas")
ggmap(hdf, extent = "normal")
(pt <- gglocator(mercator = TRUE))
last_plot() +
annotate("point", pt$lon, pt$lat, color = "blue", size = 3, alpha = .5)
}
Run the code above in your browser using DataLab