0
我很難將漸變顏色映射到某些縣級人口數據,我使用的是基本R包圖。我知道必須將顏色插值到數據框,但我不確定那是如何轉換爲地圖的。這裏是代碼我使用:如何使用地圖包映射單個美國州(MO)縣人口數據?
library(dplyr)
require(maps)
my_fake_data <- data_frame(
county = sample(c('list','of','all','counties'),115,T),
county_population = sample(1:1000000,115,T))
grey_black <- colorRampPalette(c('grey50','black'))
map_data <- my_fake_data %>%
arrange(county_population) %>%
mutate(county_population_color = grey_black(nrow(.)))
map('county','missouri',interior = T,fill =T,
col = grey_black(map_data$county_population_color))
如何讓R能夠以正確的順序繪製的顏色?我的感覺告訴我將我的數據附加到地圖的內部數據庫,但我找不到要正確執行此操作的文檔 - 或者更可能是我錯了。任何幫助將不勝感激。
[這個問題](https://stackoverflow.com/questions/24399367/plot-fill-color-map-with-usa -states-data-in-r)可能會有所幫助。 – duckmayr
嘗試'col = grey_black(10)'其中10是'grey50'和'black'之間的顏色數 – missuse