what is the difference between "normal", "device", or "panel" arguments in the extent () function of ggmaps and the meaning of maprange = FALSE

Hi everyone,

I was wondering if anyone could tell me the difference between "normal", "device", or "panel" arguments in the extent () function of ggmaps.

Also what is the meaning of maprange = FALSE?

Thanks in advance

Hi @tacoba ,
Hopefully this example answers your questions:

library(ggmap)
#> Loading required package: ggplot2
#> ℹ Google's Terms of Service: <https://mapsplatform.google.com>
#> ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
bbox <- c(left = -97.1268, bottom = 31.536245, right = -97.099334, top = 31.559652)
map <- get_stamenmap(bbox, zoom = 15)
#> ℹ Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
ggmap(map, extent = "normal")

ggmap(map, extent = "panel") # No background, grid lines, or borders

ggmap(map, extent = "device") # No axis labelling


# Generate some points, two of which lie outside the map limits
points <- data.frame(lon=c(-97.1, -97.12, -98.1, -98.5),
                     lat=c(31.54, 31.55, 31.7, 31.9),
                     class=c("A","A","B","B"))

# Doesn't plot the map because some points are outside its limits 
ggmap(map, extent = "normal", maprange=FALSE) + 
  geom_point(data=points, aes(x=lon, y=lat, shape=class), size=3)


# Force the map plotting but this excludes points outside the map limits
ggmap(map, extent = "normal", maprange=TRUE) + 
  geom_point(data=points, aes(x=lon, y=lat, shape=class), size=3)
#> Warning: Removed 2 rows containing missing values (`geom_point()`).

Created on 2022-12-11 with reprex v2.0.2

1 Like

Thanks very much DavoWW!!! Great explanation !

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.