r - 在R中的绘图上添加海岸线
问题描述
我需要制作一张插值数据所在的地图。我的绘图代码是:
library(ggplot2)
theme_set(theme_bw())
library(sf)
library(rnaturalearth)
library(rnaturalearthdata)
library(ggthemes)
world <- ne_countries(scale = "medium", returnclass = "sf")
class(world)
ggplot(data = world)+
geom_tile(data = d, aes(x = lon, y = lat, fill=x))+
geom_raster(data = d, aes(x = lon, y = lat, fill=x))+
geom_sf()+
coord_sf(xlim=c(3,35), ylim=c(52,72))
我收到了这样的情节
但我只需要国家轮廓就可以在情节上,无论是陆地还是海洋,都没有区别。ypu 可以在这个寄宿生方面帮助我吗?
解决方案
您可以在您的alpha
中设置 set ,因此它不可见。往下看;fill
geom_sf
library(ggplot2)
library(sf)
library(rnaturalearth)
library(rnaturalearthdata)
library(ggthemes)
library(rgeos)
world <- ne_countries(scale = "medium", returnclass = "sf")
ggplot() +
geom_tile(data = d, aes(x = lon, y = lat, fill=x)) +
geom_raster(data = d, aes(x = lon, y = lat, fill=x)) +
geom_sf(data = world, fill=alpha("lightgrey", 0), color="lightgrey") +
coord_sf(xlim=c(3,35), ylim=c(52,72)) +
theme_bw()
这是一个仅显示世界地图的示例。
ggplot() +
geom_sf(data = world, fill=alpha("lightgrey", 0), color="lightgrey") +
coord_sf(xlim=c(3,35), ylim=c(52,72)) +
theme_bw()
推荐阅读
- typescript - 找不到第三方模块的声明文件 - 如何声明和解决这些错误
- r - R:用 X 而不是 V 重命名数据框的列名
- javascript - 从按钮 POST 请求提交数据
- java - 458解码器UVA解释(line.charAt(i)-7)
- ruby-on-rails - 使用嵌套表单创建对象
- c - C中的 %0.f 和 %.f 有区别吗
- asp.net - 如何配置两个不同的上下文一起工作(DbContext 和 IdentityDbContext)
- client-server - 如何知道从服务器传入的 protobuf 消息的大小?
- swift - 'AuthDataResult' 没有成员 uid 错误
- powershell - 将传递给 ArgumentList 的数组中的脚本块参数一般绑定