R:Custom color palette in map with spplot

情到浓时终转凉″ 提交于 2019-12-04 13:02:40

This occurs when your zcol is numeric. Convert it to factor and your plot should appear as expected.

You can see this behaviour if you convert t1$TYPE_3 to numeric:

t1$TYPE_3.num <- as.numeric(t1$TYPE_3)
spplot(t1, 'TYPE_3.num', col.regions=c('red', 'yellow'))

So assuming there are 6 possible factor levels, with labels 0 through 5, try:

Map$Rating.fac <- factor(M$Rating, levels=0:5)

and then use zcol='Rating.fac' and pass a vector of 6 colours to col.regions.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!