使用调色板和不同数据集的TMAP
我想创建一个调色板,我的目标是按照该国拥有多少米的成绩为国家着色。我该怎么做?
这是我的数据集:
'
library(readxl)
library(sf)
library(raster)
library(dplyr)
library(spData)
library(spDataLarge)
library(tmap) # for static and interactive maps
library(leaflet) # for interactive maps
library(ggplot2) # tidyverse data visualization package
mt <- data(metro)
metro %>% count(iso_a3)
map = tm_shape(world) + tm_fill() + tm_borders()
print(map)
'
I would like to create a palette, my goal is to color the countries in proportion to how many meters they have in that country. How can I do it?
This is my dataset:
'
library(readxl)
library(sf)
library(raster)
library(dplyr)
library(spData)
library(spDataLarge)
library(tmap) # for static and interactive maps
library(leaflet) # for interactive maps
library(ggplot2) # tidyverse data visualization package
mt <- data(metro)
metro %>% count(iso_a3)
map = tm_shape(world) + tm_fill() + tm_borders()
print(map)
'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的数据集由点而不是多边形组成,因此没有边界或填充物可绘制。如果您想根据计数绘制这些点,则可以做:
The data set you are using is composed of points rather than polygons, so there are no borders or fills to draw. If you want to plot the points according to the counts, you can do: