gpt4 book ai didi

r - 在无边界 map 上画点

转载 作者:行者123 更新时间:2023-12-04 02:13:15 26 4
gpt4 key购买 nike

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)

这将产生不同颜色的点(根据它们的名称)。像这样:

enter image description here

但是,我想去除点的黑色边框。有办法吗?

最佳答案

尝试不同的形状:

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)

enter image description here

关于r - 在无边界 map 上画点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36462244/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com