如何将白框中的标签名称添加到数据框中的 ggalluvial sankey 图上的三个轴中的每一个?(见图)
“国家/地区”列包含多个国家/地区的观察结果。在下面的示例中,我关注的是带有“IE”标签的爱尔兰。如何使用下面的 ggplot 代码获取国家/地区名称的数据框?我还将为“疫苗”和“目标组”名称执行此任务,因此如果解决方案也可以包含这些列,我将不胜感激。谢谢
数据框代码和 sankey 颜色 - 数据来自欧盟 ECDC
data <- read.csv("https://opendata.ecdc.europa.eu/covid19/vaccine_tracker/csv/data.csv", na.strings = "", fileEncoding = "UTF-8-BOM")
colnames(data)[2] <- "Country"
TestData <- data
Ireland <- subset(TestData, Country == "IE")
Combined <- rbind(Ireland ) #removed other countries for ease of reading
Col1 <- "slateblue2"
Col2 <- "chartreuse2"
Col3 <- "tomato2"
Col4 <- "orange2"
Col5 <- "plum3"
Col6 <- "grey43"
Col7 <- "deeppink"
alpha <- 0.2
这是 sankey 代码 - 这是我没有正确地将标签应用到相关轴的地方
ggplot(Combined,
aes(weight = FirstDose, axis1 = Vaccine, axis2 = Country, axis3 = TargetGroup)) +
geom_alluvium(aes(fill = Vaccine, color = Vaccine),
width = 0.1, alpha = alpha, knot.pos = 0.4) +
geom_stratum(width = 0.2, color = "black") +
geom_label(stat = "stratum", label.strata = TRUE) +
scale_x_continuous(breaks = 1:3, labels = c("Vaccine", "Country", "TargetGroup")) +
scale_fill_manual(values = c(Col1, Col2, Col3, Col4, Col5, Col6, Col7)) +
scale_color_manual(values = c(Col1, Col2, Col3, Col4, Col5, Col6, Col7)) +
ggtitle("ECDC Vaccination data") +
theme_minimal() +
theme(
axis.text.x = element_text(size = 12, face = "bold")
)
这是图像 - 您可以看到轴框缺少标签