根据@missuse对这个问题的回答 Plot bathymetry and coastline using ggplot2 and marmap
通过这个脚本
Bathy <- getNOAA.bathy(lon1 = 37, lon2 = 38.7,
lat1 = -45.5, lat2 = -47.3, resolution = 1)
Bathy <- as.matrix(Bathy)
class(Bathy) <- "matrix"
Bathydf <- as.data.frame(Bathy)
Bathydf <- rownames_to_column(Bathydf, var = "Longitude")
Bathydf <- gather(Bathydf,Latitude,Depth, -1)
Bathydf <- mutate_all(.tbl = Bathydf, funs(as.numeric))
ggplot(data = ctd, aes(x = Longitude, y = Latitude)) +
geom_raster(aes(fill = Chla)) +
scale_fill_gradientn(colours = rev(my_colours)) +
geom_contour(aes(z = Chla), binwidth = 2, colour = "red", alpha = 0.2) +
geom_contour(aes(z = Chla), breaks = 0.1, colour = "darkgrey") +
geom_contour(aes(z = Chla), breaks = 0.2, colour = "darkgrey") +
geom_contour(aes(z = Chla), breaks = 0.3, colour = "black") +
geom_contour(data = subset(Bathydf, Depth < 0),aes(x = Longitude, y = Latitude, z = Depth),
bins = 10, colour = "darkgray") +
stat_contour(data = subset(Bathydf, Depth >= 0),geom="polygon",
aes(z = Depth), fill = "black") +
geom_contour(data = Bathydf, aes(z = Depth), breaks = 1000, colour = "black", alpha = 1) +
geom_point(data = ctd, aes(x = Longitude, y = Latitude),
colour = 'black', size = 3, alpha = 1, shape = 15) +
theme(panel.background = element_blank()) +
theme(aspect.ratio=1)
它有效,但我不确定使用stat_contour()
是否是绘制区域的最佳方式。此外,绘制岛屿的区域,它也为它们的某些部分着色,使形状有线。
您认为使用stat_contour()
是绘制区域的最佳方式吗?您知道为什么它还会绘制大黑区周围的有线点吗?
答案 0 :(得分:1)
您是否检查了marmap::autoplot.bathy
的帮助文件?您是否查看了那里的示例,尤其是geom="contour"
参数?它没有做你想要达到的目标吗?