Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How ggplot draws Central density radiation Map in R language Visualization

Shulou Source: shulou.com Published: 2022-06-01 22:20:32 10月01日 Update

It is believed that many inexperienced people have no idea about how to draw the central density radiation map by ggplot in R language visualization. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Because we have not seen a good solution to the density radiation map (or thermal radiation map, which is the type of chart in PowerMap that can detect the distribution density of regional indicators by color chromaticity) in ggplot2, I recently read the introduction post of ggmap on the Github. com, and saw that the author nested geom_polygon layer in the ggmap function and used fill=..level... Parameters and stat= "density_2d" to make a similar thermal radiation map.

It occurred to me whether it would be possible to use the ggplot function instead of ggmap. The method is introduced as follows:

First, you need to load the following package:

Library (ggplot2)

Library (plyr)

Library (maptools)

Library (ggmap)

Next, import two datasets:

One of them is the outline map of China's provincial boundary. Early users who have followed the Rubik's Cube probably know that I once shared a file package called rstudy (I found it in Mr. Liu Wanxiang's official account, which should also be available now). If you don't have the data on hand, you can add the QQ group of Rubik's Cube Academy and look for R language materials in the group sharing. (there are a lot of shared files, which may take a while to find.)

The other is the data set of the city value index used in explaining the REmap heat radiation map, which will be shared in the QQ group of the Rubik's cube after being pushed.

Import the dataset:

China_map

Tags: Data radiation index density map heat chart city language effect method Rubik's cube visualization code content function region parameter name academy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi NVidia Microsoft Apple