本文介绍了在无边界的地图上绘制点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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?
推荐答案
尝试其他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)
或在使用shape = 21
时将color
设置为NA
:
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)
这篇关于在无边界的地图上绘制点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!