我有一张地图,上面有一些点是用geom_point
. 它们位于我需要它们的确切位置和颜色,但我正在尝试将形状更改为我从 phylopic 导入的轮廓。这是代码的一些示例数据
#Dataframe for the points
individual_dets = data.frame(longitude= seq(-64.5,-62.4,0.1),
latitude= seq(42.7,44.8,0.1),
year = sample(c(2016, 2017, 2018), 22, replace = T),
Zone = sample(c(1:4), 22, replace = T),
month = sample(month.abb, 22, replace = T))
下面是我导入的系统轮廓的代码,以及我的带有点的地图的代码
library(rphylopic)
library(RCurl)
library(png)
library(mapdata)
#Import phylopic
rayurl = "http://phylopic.org/assets/images/submissions/a3b3e80c-22f2-4b8f-a3ac-42fe1583e0be.thumb.png"
raylogo = readPNG(getURLContent(rayurl))
#Importing the map
canada = map_data("worldHires", "Canada")
#The Map
ggplot() +
geom_polygon(data = canada,
aes(x=long, y=lat, group=group),
colour="grey50", fill = 'grey55')+
#Coordinates I'm interested in looking at
coord_sf(xlim=c(-64.5,-62.8), ylim=c(42.7,45)) +
geom_point(data = individual_dets,
aes(x = longitude,
y = latitude,
color = as.factor(Zone)),
#fill = as.numeric(Zone)),
size = 5) +
scale_color_manual(values=c("#01579B", "#4FC3F7", "#ffa600", "#ff6361"),
name = "Zone")
有谁知道如何获取这个保存的剪影并将其放置在与我的点相同的坐标和相同的颜色上?