我无法在 R 中使用 ggmap/ggplot2 在地图顶部绘制填充等高线图。
我的数据是定期间隔的纬度/经度坐标,az 值表示降雨量
> head( flood )
lat lon rain
1 22.51916 -105.9318 1.486188e-05
2 22.59956 -105.9318 1.735962e-05
3 22.67996 -105.9318 2.024598e-05
4 22.76037 -105.9318 2.357599e-05
5 22.84077 -105.9318 2.741153e-05
6 22.92117 -105.9318 3.182212e-05
用ggmap获得底图后,我试图覆盖雨的填充轮廓
map = ggmap( baseMap ) +
geom_contour( data = flood, aes( x = lon, y = lat, z = rain ) ) +
scale_fill_continuous( name = "Rainfall (inches)", low = "yellow", high = "red" )
这给了我一个错误
Error in unit(tic_pos.c, "mm") : 'x' and 'units' must have length > 0
如果我做
map = ggmap( baseMap ) +
geom_contour( data = flood, aes( x = lon, y = lat, z = rain, fill = ..level.. ) ) +
scale_fill_continuous( name = "Rainfall (inches)", low = "yellow", high = "red" )
我得到这个情节没有实际的填充。
我一直在尝试关注这篇文章和 这篇文章,但我无法解决我的问题。我对 ggplot/R 了解不多,但到目前为止我已经能够偶然发现它。..level.. 是什么意思?
我认为这篇文章可能是相关的,但我无法将修复概括为适用于等高线图。