I have trying to change my legends and the names of the countries that appear multiple times in one of the areas plots.
i. As you can see the legend appears several times. I want this legend to be place like in the last picture. for both: symptoms and comorbidities:
- if this can appear above the whole plot as: Symptoms: chest pains, chills, etc. and Comorbidities: asthma, diabetes type one, etc.
ii. the sizes of each area plots are different
- They should be equal in size.
iii. Also the country labels. Nicely, these are appearing once. Would want them to appear like the last picture:
A - India, B - Pakistan, C - United Kingdom and positioned on the left hand side above each set of area plots.
Here is an example of the way I want my plot to look like
Here is the code and the fake datasets:
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
Is there a way I can get them the way I want. Help is very much appreciated.