【858】tm_polygons专题地图多图层R语言
ref: tm_polygons: Draw polygons
Arguments
alpha |
transparency number between 0 (totally transparent) and 1 (not transparent). By default, the alpha value of the |
palette |
a palette name or a vector of colors. See |
breaks |
in case |
midpoint |
The value mapped to the middle color of a diverging palette. By default it is set to 0 if negative and positive values are present. In that case, the two sides of the color palette are assigned to negative respectively positive values. If all values are positive or all values are negative, then the midpoint is set to |
title |
title of the legend element |
legend.show |
logical that determines whether the legend is shown |
popup.vars |
names of data variables that are shown in the popups in 设置为 |
☀☀☀<< 举例 >>☀☀☀
library(tidyverse) library(sf) library(ggplot2) library(tmap) tmap_mode("view") # Set default work directory setwd("/Users/libingnan/Documents/09-Samsung/25-New paper-Hotspot-Monkeypox/Data/socioecnomic_data/world_level_socioeconomic_data") hist <- st_read("socioeconomic_factors_world.gpkg") tm_shape(hist, name = "Average Temperature (JAN)") + tm_polygons("avg_tavgs", title = "Average Temperature", palette = "viridis", midpoint=NA, popup.vars=TRUE) + tm_shape(hist, name = "Minimum Temperature (JAN)") + tm_polygons("avg_tmins", title = "Minimum Temperature", palette = 'viridis', midpoint=NA, popup.vars=TRUE) + tm_shape(hist, name = "Maximum Temperature (JAN)") + tm_polygons("avg_tmaxs", title = "Maximum Temperature", palette = 'viridis', midpoint=NA, popup.vars=TRUE) + tm_shape(hist, name = "Elevation") + tm_polygons("avg_elevs", title = "Elevation", palette = 'Blues', midpoint=NA, popup.vars=TRUE) + tm_shape(hist, name = "NDVI (JAN)") + tm_polygons("avg_ndvis", title = "NDVI", palette = 'Greens', midpoint=NA, popup.vars=TRUE, breaks = c(0, 40, 80, 120, 160, 200)) + tm_shape(hist, name = "Precipitation (JAN)") + tm_polygons("avg_precs", title = "Precipitation", palette = 'Blues', midpoint=NA, popup.vars=TRUE, breaks = c(0, 80, 160, 240, 320, 400)) + tm_shape(hist, name = "Water vapor pressure (JAN)") + tm_polygons("avg_vaprs", title = "Water vapor pressure", palette = 'Oranges', midpoint=NA, popup.vars=TRUE) + tm_shape(hist, name = "Wind speed (JAN)") + tm_polygons("avg_winds", title = "Wind speed", palette = 'Blues', midpoint=NA, popup.vars=TRUE) + tm_shape(hist, name = "Solar radiation (JAN)") + tm_polygons("avg_srads", title = "Solar radiation", palette = 'Oranges', midpoint=NA, popup.vars=TRUE) + tm_shape(hist, name = "Population density") + tm_polygons("pop_est_dens", title = "Population", palette = "Reds", midpoint=NA, popup.vars=TRUE)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2021-07-12 【604】Python class __dict__.update的使用
2021-07-12 【603】Python 实现 for 和 if 单行显示
2019-07-12 【425】堆排序方法(二叉堆)优先队列(PQ)