我正在嘗試制作一個簡單的歐盟多面圖,但覆寫歐盟的底圖。我只是想知道是否有可能做到這一點?
現在,我的代碼如下,它產生以下內容:
mydf %>%
ggplot(aes(x = x, y = y, group = name))
geom_line()
coord_polar()
facet_geo(~country, grid = "eu_grid1")

我可以使用以下內容輕松制作歐洲地圖:
world <- map_data("world")
world %>%
filter(region %in% eu_grid1$name) -> europe
ggplot()
geom_polygon(data=europe, aes(x=long, y=lat, group=group), color="black", fill="white")
但無法弄清楚如何同步(如果可能)并將它們分層。謝謝!
uj5u.com熱心網友回復:
是的,這是可能的。我不確定它在視覺上的效果如何。顯然我沒有你的資料,但我將使用一個內置的資料集geofacet來演示。
library(geofacet)
library(grid)
library(tidyverse)
facets <- eu_gdp %>%
ggplot(aes(x = year, y = gdp_pc))
geom_line()
facet_geo(~name, grid = "eu_grid1")
theme(plot.background = element_blank())
map_data("world") %>%
filter(region %in% eu_grid1$name) %>%
ggplot()
geom_polygon(aes(x=long, y=lat, group=group),
color="black", fill="white")
theme_void()
print(facets, newpage = FALSE)

由reprex 包于 2022-03-09 創建(v2.0.1)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/443281.html
上一篇:在ggbreak中設定刻度值
