gglocator: Locator for ggplot objects

Description Usage Arguments Value Author(s) Examples

Description

Locator for ggplot objects (Note : only accurate when extent = "normal" when using ggmap.)

Usage

1
gglocator(n = 1, message = FALSE, mercator = TRUE, ...)

Arguments

n

number of points to locate.

message

unused

mercator

logical flag; should the plot be treated as using the projection common to most web map services? Set to FALSE if the axes on the plot use a linear scale.

...

additional arguments (including deprecated, e.g. xexpand)

Value

a data frame with columns according to the x and y aesthetics

Author(s)

Tyler Rinker, Baptiste Auguie, DWin, David Kahle, \@Nikolai-Hlubek and \@mvkorpel.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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)

}

ggmap documentation built on May 1, 2019, 8:22 p.m.