輕鬆將數據從Map打包成適合使用 ggplot2 繪圖的 DataFrame 。
參數
- map
 - 
提供的Map名稱Map包。這些包括
maps::county(),maps::france(),maps::italy(),maps::nz(),maps::state(),maps::usa(),maps::world(),maps::world2(). - region
 - 
要包括的次區域名稱。默認為
.,其中包括所有子區域。有關更多詳細信息,請參閱maps::map()的文檔。 - exact
 - 
應該將
region視為正則表達式 (FALSE) 還是固定字符串 (TRUE)。 - ...
 - 
所有其他參數傳遞給
maps::map() 
例子
if (require("maps")) {
states <- map_data("state")
arrests <- USArrests
names(arrests) <- tolower(names(arrests))
arrests$region <- tolower(rownames(USArrests))
choro <- merge(states, arrests, sort = FALSE, by = "region")
choro <- choro[order(choro$order), ]
ggplot(choro, aes(long, lat)) +
  geom_polygon(aes(group = group, fill = assault)) +
  coord_map("albers",  lat0 = 45.5, lat1 = 29.5)
}
if (require("maps")) {
ggplot(choro, aes(long, lat)) +
  geom_polygon(aes(group = group, fill = assault / murder)) +
  coord_map("albers",  lat0 = 45.5, lat1 = 29.5)
}
相關用法
- R ggplot2 mean_se 計算平均值和平均值的標準誤差
 - R ggplot2 annotation_logticks 注釋:記錄刻度線
 - R ggplot2 vars 引用分麵變量
 - R ggplot2 position_stack 將重疊的對象堆疊在一起
 - R ggplot2 geom_qq 分位數-分位數圖
 - R ggplot2 geom_spoke 由位置、方向和距離參數化的線段
 - R ggplot2 geom_quantile 分位數回歸
 - R ggplot2 geom_text 文本
 - R ggplot2 get_alt_text 從繪圖中提取替代文本
 - R ggplot2 annotation_custom 注釋:自定義grob
 - R ggplot2 geom_ribbon 函數區和麵積圖
 - R ggplot2 stat_ellipse 計算法行數據橢圓
 - R ggplot2 resolution 計算數值向量的“分辨率”
 - R ggplot2 geom_boxplot 盒須圖(Tukey 風格)
 - R ggplot2 lims 設置規模限製
 - R ggplot2 geom_hex 二維箱計數的六邊形熱圖
 - R ggplot2 scale_gradient 漸變色階
 - R ggplot2 scale_shape 形狀比例,又稱字形
 - R ggplot2 geom_bar 條形圖
 - R ggplot2 draw_key 圖例的關鍵字形
 - R ggplot2 annotate 創建注釋層
 - R ggplot2 label_bquote 帶有數學表達式的標簽
 - R ggplot2 annotation_map 注釋:Map
 - R ggplot2 scale_viridis 來自 viridisLite 的 Viridis 色標
 - R ggplot2 coord_fixed 具有固定“縱橫比”的笛卡爾坐標
 
注:本文由純淨天空篩選整理自Hadley Wickham等大神的英文原創作品 Create a data frame of map data。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
