2017-10-03 13 views
1

choroplethマップを作成するために、tm_fill関数内で使用できるカラーパレットを作成しようとしています。私は現在、プリセットカラーパレットを使用していますが、私は、その後でpalette = sequential_hcl(8, alpha=0.6)を置き換えるcoudld独自のカスタムを作成する方法があった場合、私は思っていた瞬間tm_fillのカラーパレットを作成する

tm_shape(LdnCensusMap) + tm_borders(col = 'Grey', alpha = 0.3) + tm_fill(col = "Privaterent", palette = sequential_hcl(8, alpha=0.6), title = "Privately Rented (%)", style = "equal", n = 8,) + tm_shape(ldn) + 

感謝

答えて

0

あなたは正しい、パッケージtmapsを使用していますか?彼らは、この例で行ったようにあなたは(パッケージのドキュメントにある)、RColorBrewerでパレットを作成することができます。

data(World, Europe, NLD_muni, NLD_prov, land, metro) 

if (require(RColorBrewer)) { 
pal <- brewer.pal(10, "Set3")[c(10, 8, 4, 5)] 
tm_shape(Europe) + 
tm_polygons("EU_Schengen", palette=pal, title = "European Countries", 
showNA=FALSE) + 
tm_format_Europe() 
} 

ます。また、HEX形式で色を選択し、次のようにパレットを設定することができます。

# Random colors in HEX. 
Mypal <- c('#313695','#fee090','#d73027','#72001a') 

# Ploting the ma again with my custom palette 
tm_shape(Europe) + 
tm_polygons("EU_Schengen", palette=Mypal, title = "European Countries", 
showNA=FALSE) + 
tm_format_Europe() 
関連する問題