Draw Point on Map Without Border

邮差的信 提交于 2019-12-24 02:54:35

问题


library(ggplot2)
library(ggmap)
data <- read.table(file = "data.txt", sep = ",", col.names = c("lat", "lon", "place_name"), fill=FALSE, strip.white=TRUE)

# getting the map
mapgilbert <- get_map(location = c(lon = mean(data$lon), lat = mean(data$lat)),
              zoom = "auto" , maptype = "roadmap", scale = 2, color = "bw")

# plotting the map with some points on it
ggmap(mapgilbert, extent = "device") +
  geom_point(data = data, aes(x = lon, y = lat, fill = place_name), size = 0.5, shape = 22) +
  guides(fill=FALSE, alpha=FALSE, size=FALSE)

This will produce points with different color (According to their names). Something like this:

However, I want to get rid of the black border of the points. Is there a way to do that?


回答1:


Try a different shape:

data <- data.frame(lat=52.5176736, lon=13.3895097)
library(ggmap)
library(ggplot2)
mapgilbert <- get_map(location = c(lon = mean(data$lon), lat = mean(data$lat)),
              zoom = "auto" , maptype = "roadmap", scale = 2, color = "bw")
ggmap(mapgilbert, extent = "device") +
  geom_point(data = data, aes(x = lon, y = lat), size = 6, shape = 16, color="red") +
  guides(fill=FALSE, alpha=FALSE, size=FALSE)

or set color to NA when using shape = 21:

ggmap(mapgilbert, extent = "device") +
  geom_point(data = data, aes(x = lon, y = lat), size = 6, shape = 21, color=NA, fill = "red") +
  guides(fill=FALSE, alpha=FALSE, size=FALSE)



来源:https://stackoverflow.com/questions/36462244/draw-point-on-map-without-border

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!