ggtitle 不显示 ggmap

ggtitle not displaying with ggmap

我不明白为什么 ggtitle("My Title") + 或 labs(title = "My Title") + 没有显示我的标题。这是我的代码:

require(raster)
country <- getData("GADM", country="Australia",level = 0)

points <- data.frame(id = c(1:5), lon = c(125, 144, 150, 115, 139), lat = c(-20, -15, -34, -25, -21))
edges <- data.frame(from.lon = c(144, 139, 125), from.lat = c(-15,-21, -20), to.lon = c(150, 125, 144), to.lat = c(-34, -20, -15), resource_id = c(1:3))

centrepoint <- as.numeric(geocode("Australia"))


p1 <- ggmap(get_googlemap(center = centrepoint, scale = 2, zoom = 4,    maptype = "satellite"), extent = "device") +
  geom_polygon(data = country, aes( x = long, y = lat, group = group),  fill = NA, color = "white", size = 0.25) +
  geom_segment(data = filter(edges, edgelist$resource_id == 2),
               size = 0.5,
               color = "pink",
               aes(y = from.lat, x = from.lon, yend =  to.lat, xend = to.lon),
           arrow = arrow(length = unit(0.25, "cm"), type = "closed")) +
  coord_fixed(1.3) +
  geom_point(aes(x = lon, y = lat), data = points, col = "pink", alpha = 0.5, size = 1.0) +
  ggtitle("Money") +
  theme(plot.margin = unit(c(1,1,1,1), "cm"))
p1

我还在学习ggplot。

如果没有至少最少的可重现数据,回答这个问题有点困难。如果没有这些信息,您的 geom 调用之一(我的猜测是 geom_polygon())或相关数据似乎有问题,因为它工作正常:

library(ggplot2)
library(ggmap)

ggmap(
  get_googlemap(
    scale = 2, 
    zoom = 7, 
    maptype = "satellite"
    ), 
  extent = "device") +
  coord_fixed(1) +
  labs(title = "Money") + 
  # ggtitle("Money)
  theme(plot.margin = unit(c(1,1,1,1), "cm"))