Smoothing out ggplot2 map

前端 未结 2 1505
旧巷少年郎
旧巷少年郎 2020-12-08 11:34

Previous Posts

Cleaning up a map using geom_tile

Get boundaries to come through on states

Problem/Question

I\'m trying to smooth out some

2条回答
  •  既然无缘
    2020-12-08 12:22

    The previous answer was prbly not optimal (or accurate) for your needs. This is a bit of a hack:

    gg <- ggplot() 
    gg <- gg + geom_polygon(data=subset(map_data("state"), region %in% regions), 
                            aes(x=long, y=lat, group=group))
    gg <- gg + geom_point(data=PRISM_1895_db, aes(x=longitude, y=latitude, color=APPT), 
                          size=5, alpha=1/15, shape=19)
    gg <- gg + scale_color_gradient(low="#023858", high="#ece7f2")
    gg <- gg + geom_polygon(data=subset(map_data("state"), region %in% regions), 
                            aes(x=long, y=lat, group=group), color="white", fill=NA)
    gg <- gg + coord_equal()
    gg
    

    that requires changing size in geom_point for larger plots, but you get a better gradient effect than the stat_summary2d behavior and it's conveying the same information.

    enter image description here

    Another option would be to interpolate more APPT values between the longitude & latitudes you have, then convert that to a more dense raster object and plot it with geom_raster like in the example you provided.

提交回复
热议问题