根据自定义间隔创建带颜色的点符号地图
Creating point symbols map with color based on an custom intervals
基本上,accessibility_round
的值可以来自 >0 to Inf
因此我想根据以下规则为点着色。
>0 to 20 - Color1
>20 to 100 - Color2
>100 to 1000 - Color3
>1000 to 10000 - Color4 (assume no value larger than 10000 except Inf)
Inf - Color5
我是 R 的新手,刚开始使用 tmap,我不确定如何设置自定义间隔。但这是我迄今为止尝试过的。
tm_shape(schools)+
tm_symbols(title.col = "Accessibility", style = "fixed",breaks = c(0,20,100,1000,10000,Inf), col="accessibility_round",size = 0.3,
palette = "Accent", auto.palette.mapping = FALSE,interval.closure = "right") +
tm_layout(legend.outside = TRUE, legend.outside.position = "bottom", legend.stack = "horizontal")
到底是什么不起作用?如果我理解正确的话,这就可以了:
data(World)
World$pop_est[World$pop_est>1e9] <- Inf
tm_shape(World) +
tm_symbols(col="pop_est",size = 0.3,
title.col = "Population",
style = "fixed",
breaks = c(0,1e6,1e7,1e8,1e9,Inf),
palette = "Accent",
auto.palette.mapping = FALSE,
interval.closure = "right",
labels = c("0 to 1e6", "1e6 to 1e7", "1e7 to 1e8", "1e8 to 1e9", "Inf")) +
tm_shape(World[which(World$pop_est==Inf),]) +
tm_text("name") +
tm_layout(legend.outside = TRUE, legend.outside.position = "bottom", legend.stack = "horizontal")
基本上,accessibility_round
的值可以来自 >0 to Inf
因此我想根据以下规则为点着色。
>0 to 20 - Color1
>20 to 100 - Color2
>100 to 1000 - Color3
>1000 to 10000 - Color4 (assume no value larger than 10000 except Inf)
Inf - Color5
我是 R 的新手,刚开始使用 tmap,我不确定如何设置自定义间隔。但这是我迄今为止尝试过的。
tm_shape(schools)+
tm_symbols(title.col = "Accessibility", style = "fixed",breaks = c(0,20,100,1000,10000,Inf), col="accessibility_round",size = 0.3,
palette = "Accent", auto.palette.mapping = FALSE,interval.closure = "right") +
tm_layout(legend.outside = TRUE, legend.outside.position = "bottom", legend.stack = "horizontal")
到底是什么不起作用?如果我理解正确的话,这就可以了:
data(World)
World$pop_est[World$pop_est>1e9] <- Inf
tm_shape(World) +
tm_symbols(col="pop_est",size = 0.3,
title.col = "Population",
style = "fixed",
breaks = c(0,1e6,1e7,1e8,1e9,Inf),
palette = "Accent",
auto.palette.mapping = FALSE,
interval.closure = "right",
labels = c("0 to 1e6", "1e6 to 1e7", "1e7 to 1e8", "1e8 to 1e9", "Inf")) +
tm_shape(World[which(World$pop_est==Inf),]) +
tm_text("name") +
tm_layout(legend.outside = TRUE, legend.outside.position = "bottom", legend.stack = "horizontal")