我正在绘制一个栅格并用两个多边形覆盖它。我想分别为每个 shapefile 绘制图例(即缓冲区图例和每个多边形的一个图例)。我show.legend = TRUE
在里面使用过,geom_path
但它没有给我想要的东西。我正在使用此代码。
gplot(pfiles) +
geom_raster(aes(fill = factor(value))) +
geom_path(data=ward, aes(long, lat, group=group), color = "black") +
geom_path(data=buffer, aes(long, lat, group=group), color = "red") +
facet_wrap(~ variable, ncol = 4) +
scale_fill_manual(values = c("darkorchid", "chartreuse3", "cornflowerblue", "goldenrod2"),
na.value="transparent", na.translate = F) +
guides(fill = guide_legend(title = "Buffer Zones")) +
#scale_color_identity(guide = "legend") +
theme_bw() +
theme(axis.text = element_blank(), legend.position = "right", legend.direction = "vertical",
axis.title = element_blank(),
legend.key.height = unit(2, "cm"), legend.key.width = unit(1, "cm"),
legend.title = element_text(size = 22, face = "bold"), legend.text = element_text(size = 20),
strip.text = element_text(size = 18, face = "bold"),
plot.title = element_text(size = 20, face = "bold"),
plot.subtitle = element_text(size = 15), plot.caption = element_text(size = 12, face = "bold.italic"),
panel.background = element_rect(fill = "transparent")) +
labs(title = "Variables for Identification of Potential Urban Development Zones",
subtitle = "Land Price and Ground Water Level represent price and water depth respectively; Others represent Euclidean Distance") +
coord_equal()