我试图更改我的传说和在其中一个区域图中多次出现的国家/地区的名称。
一世。如您所见,图例出现了好几次。我希望这个传说出现在最后一张照片中。对于两者: 症状和合并症:
- 如果这可以在整个图上方显示为:症状:胸痛、发冷等和合并症:哮喘、1 型糖尿病等。
ii. 每个区域地块的大小不同
- 它们的大小应该相等。
iii. 还有国家标签。很好,这些只出现过一次。希望它们看起来像最后一张图片:
A - 印度,B - 巴基斯坦,C - 英国,位于每组区域图上方的左侧。
这是代码和假数据集:
sympt_count_plot <- ggplot2::ggplot(count_symptoms, ggplot2::aes(x = age_band, y = Count, group = symptoms, fill = symptoms)) +
ggplot2::geom_area( color = "white") +
ggplot2::scale_x_discrete(limits = c( "0-19" ,"20-39", "40-59","60+"), expand = c(0, 0)) +
ggplot2::scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
viridis::scale_fill_viridis(discrete = TRUE) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
ggplot2::facet_grid(Country ~.)
sympt_count_plot
sympt_percent_plot <- ggplot2::ggplot(count_symptoms, ggplot2::aes(x = age_band, y = Percent, group = symptoms, fill = symptoms)) +
ggplot2::geom_area( color = "white") +
ggplot2::scale_x_discrete(limits = c( "0-19" ,"20-39", "40-59","60+"), expand = c(0, 0)) +
ggplot2::scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
viridis::scale_fill_viridis(discrete = TRUE) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
ggplot2::facet_grid(Country ~.)
sympt_percent_plot
library(patchwork)
plot_sympt <- sympt_count_plot + sympt_percent_plot
plot_sympt
comorb_count_plot <- ggplot2::ggplot(count_comorbidities, ggplot2::aes(x = age_band, y = Count, group = comorbidities, fill = comorbidities)) +
ggplot2::geom_area( color = "white") +
ggplot2::scale_x_discrete(limits = c( "0-19" ,"20-39", "40-59","60+"), expand = c(0, 0)) +
ggplot2::scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
#viridis::scale_fill_viridis(discrete = TRUE) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
ggplot2::facet_grid(Country ~.)
comorb_count_plot
comorb_percent_plot <- ggplot2::ggplot(count_comorbidities, ggplot2::aes(x = age_band, y = Percent, group = comorbidities, fill = comorbidities)) +
ggplot2::geom_area( color = "white") +
ggplot2::scale_x_discrete(limits = c( "0-19" ,"20-39", "40-59","60+"), expand = c(0, 0)) +
ggplot2::scale_y_continuous(expand = expansion(mult = c(0, 0.1))) +
#viridis::scale_fill_viridis(discrete = TRUE) +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) +
ggplot2::facet_grid(Country ~.)
comorb_percent_plot
plot_comorb <- comorb_count_plot + comorb_percent_plot
plot_comorb
plot_sympt + plot_comorb
有没有办法我可以按照我想要的方式得到它们。非常感谢您的帮助。