2016-10-10 11 views
0

私はかなり単純な問題に苦しんでいると思いますが、私はそれを自分で解決するか、解決策があるかもしれない投稿を見つけることに失敗しています。私はアメリカをプロットして、マップにポイントを追加しています。しかし、地図をプロットすると、統計のアウトラインは表示されません。助言がありますか?おそらく、私が疑問に思った道案内で、適切な地図を使用していないのでしょうか?以下のコード。ヘルプとアドバイスを事前に感謝します。米国の州の概要はggplot2には表示されません

study2 <- c("ABQ", "ATL", "BUF", "CHS", "DEN", "MEM", "ORF", "Apker", "Apker", "Drewry", "Gardner", "Gould", "Gould", "Gould", "Hooker", "Sun", "Tredick", "Tredick", "Tredick", "Wilton") #city and study labels 
lat2 <- c(35.5, 33.44, 42.52, 32.53, 39.44, 35.9, 36.50, 37.18, 39.7, 33.23, 44.1, 36.1, 35.6, 33.4, 32.3, 41.8, 36.31, 36, 36, 36.3) 

long2 <- c(-106.36, -84.23, -78.52, -80.10, -104.59, -90.2, -76.17, -104.55, -107.51, -79.12, -75.45, -105.19, -106.23, -105.42, -83.3, -77.48, -76.27, -76.29, -76, -92.51) 

elev.df2 <- data.frame(study2, lat2, long2) 

shape2 <- c(15, 1, 19, 17, 2, 0, 18, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8) 

states <- map_data("state") 


uv.map <- ggplot() + 

      coord_fixed() + 

    geom_polygon(data = states, 
       aes(x = long, y = lat, group = group), fill = "gray90") + 

    geom_point(data = elev.df2, 
      aes(x = long2, y = lat2), 
      shape = shape2, 
      col = "black", 
      size = c(4,4,4,4,4,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2)) + 

    labs(x = "Longitude", y = "Latitude", title = "") + 

    theme_bw() + 

    theme(panel.grid.major = element_blank(), 
     panel.grid.minor = element_blank(), 
     axis.line = element_line(colour = "black")) + 

    coord_equal(ratio=1) 

enter image description here

答えて

4

状態の境界はgeom_polygoncolor=パラメータを使用して描画されます。ちょうどあなたが

geom_polygon(data = states, 
    aes(x = long, y = lat, group = group), 
    fill = "gray90", 
    color="black") 

enter image description here

+0

おかげで、MrFlickを好きな色に設定します。私は思ったほど簡単でした。助けてくれてありがとう。 –

+0

でも...しかし... 'coord_map(" polyconic ")' :-) – hrbrmstr

関連する問題