【发布时间】:2021-12-22 23:54:51
【问题描述】:
我想用下面的代码创建一个热图。
data_smoothed = ggplot() +
metR::geom_contour_fill(data = data.dolphins, aes(x = lon, y = lat, z = density),
bins = 120, na.fill = TRUE)+
coord_sf(xlim = c(-1, 5), ylim = c(37,43))+ #I want to change this
scale_fill_viridis_c() +
metR::scale_x_longitude(ticks = 2)+
metR::scale_y_latitude(ticks=2)+
theme_bw() +
ggtitle("dolphins")+
theme(plot.title = element_text(hjust = 0.5))
返回这个: enter image description here
但是,我不想收到这个,我只想保留热图的这些部分,这些部分属于我已经拥有的多面体。
> poly
Simple feature collection with 1 feature and 0 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -1 ymin: 37 xmax: 6 ymax: 42.42764
Geodetic CRS: WGS 84
geometry
1 MULTIPOLYGON (((0.5 39.5, 0...
即类似于下面显示的多边形内的热图部分。 enter image description here
有什么想法吗?
【问题讨论】:
标签: r ggplot2 heatmap kernel-density