R语言绘制分块区域热力图
作者:互联网
REmap包绘制2020年我国31个省市自治区GDP总量区域热力图
今天用的是REmap包中的remapC()函数绘制分块区域热力,下面以2020年我国各省31各省市自治区GDP总量数据(单位是亿元)为例画一个分块区域热力图,展现不同省市GDP总量分布效果。
library(REmap)
options(remap.js.web=T)
##创建数据框
city<-c("广东","江苏","山东","浙江","河南","四川","福建","湖北","湖南","上海","安徽","河北","北京","陕西","江西","辽宁","重庆","云南","广西","贵州","山西","内蒙古","天津","新疆","黑龙江","吉林","甘肃","海南","宁夏","青海","西藏")
gdp<-c(110761,102719,73129,64613,54997,48599,43904,43443,41781,38701,38681,36207,36103,26182,25692,25115,25003,24522,22157,17827,17652,17360,14084,13798,13699,12311,9017,5532,3921,3006,1903)
data1<-data.frame(city,gdp)
##或者读取表格数据
library(readxl)
options(remap.js.web=T)
data<- read_excel("GDP.xlsx")
data1<-data.frame(data$省市,data$GDP)
(数据参考:https://baijiahao.baidu.com/s?id=1690217981017547282&wfr=spider&for=pc)
#根据需求设置主题
theme1 <- get_theme(theme = "none",#可选“Dark”,“Sky”,“blue”,“none”四种,当设置get_theme其他参数时,需要将该参数设置为“none”
backgroundColor = "#CCCCCC", #背景色
titleColor = "#fff",#标题颜色
labelShow = T, #是否展示各省市名称
pointShow = T, #是否展示各省会所在点
pointColor = "gold")#上述点颜色
##或者直接绘图
remapC(data1,
title = '2020年全国GDP总量热力图',
maptype = 'china',
theme = theme1,
color = 'red',
maxdata = 120000,
mindata = 1500)
“作图帮”公众号同步更新~
标签:GDP,REmap,分块,##,力图,绘制 来源: https://blog.csdn.net/weifanbio/article/details/117509824