2013-04-02 7 views
7

私はこのコードをマップデータパッケージを使用していますが、選択した3国のみを表示しています。世界の地図境界。rworldmapライブラリと地図機能を使用して特定の国(エチオピア、ウガンダ、ケニア)を強調表示

map("world", 
    regions=c("ethiopia", "kenya", "uganda"), 
    exact = TRUE, 
    fill=TRUE, 
    col=c(1,2,3)) 

3つの選択された国を強調表示しながら、残りの世界地図の境界線を表示するにはどうすればよいですか?ここで

答えて

10

はrworldmapなしの例です。

require(mapdata) 

# get the names 
cc <- map('world', names = TRUE, plot = FALSE) 
take <- unlist(sapply(c("ethiopia", "kenya", "uganda"), grep, tolower(cc), value = TRUE)) 

# world 
map() 
# add the selected countries in grey to the plot 
map('world', regions=take, fill=TRUE, col='grey50', add = TRUE) 

enter image description here

+2

+1、私はもう少しの国を強調するために、= "赤" ''または類似BORを使用すると思います。 –

+0

ありがとう、サイモン。ちょうど私が欲しかった!完璧! – Carvalho

関連する問題