我在ggmap
包中使用了 Stamen 背景图。我想替换光栅背景图像中的所有黑色元素(即颜色"#000000"
与say "#C0C0C0"
- 基本上看起来更像墨粉背景图)。
library(ggmap)
loc <- c(left = -73.706, bottom = 42.6940, right = -73.648, top = 42.7921)
troy <- get_map(location = loc, zoom = 13, maptype = "toner", source = "stamen")
ggmap(troy)
按照以下替换颜色仅返回光栅部分,并剥离其 ggmap 类的对象。
class(troy)
troy[troy == "#000000"] <- "#C0C0C0"
ggmap(troy)
class(troy)
有没有办法在不改变其他属性的情况下替换栅格单元?