Below is the snapshot of my dataset
Town Age_Group Race Count_Type Total_Count
<chr> <chr> <chr> <chr> <dbl>
1 Milwaukee 12-17 White Initial 500
2 Milwaukee 12-17 White Full 424
3 Milwaukee 12-17 Black Initial 1080
4 Milwaukee 12-17 Black Full 771
5 Milwaukee 12-17 AmerIndian Initial 11
6 Milwaukee 12-17 AmerIndian Full 5
Code for the plot, I should also mention that ggplot2 is a hard requirement
# Visualization
ggplot(data = milwaukee, aes(x = Age_Group, y = Total_Count, fill = Race)) +
geom_bar(stat = 'identity', position = 'stack') +
labs(x = 'Age Group', y = 'Total Vaccinated by Age Group',
title = 'Milwaukee Total Vaccinated by Age Group & Race') +
# scale_y_continuous(trans = 'log2') +
geom_text(aes(label = scales::number(Total_Count, big.mark = ',', accuracy = 1)), size = 2,
position = position_stack(vjust = 0.5)) +
theme_classic() +
theme(text = element_text(size = 9, family = 'mono'),
legend.position = 'bottom',
plot.title = element_text(hjust = 0.5, size = 11))
Sample data
> dput(milwaukee)
structure(list(Town = c("Milwaukee", "Milwaukee", "Milwaukee",
"Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee",
"Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee",
"Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee",
"Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee",
"Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee",
"Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee",
"Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee", "Milwaukee",
"Milwaukee", "Milwaukee"), Age_Group = c("12-17", "12-17", "12-17",
"12-17", "12-17", "12-17", "12-17", "12-17", "18-24", "18-24",
"18-24", "18-24", "18-24", "18-24", "18-24", "18-24", "25-44",
"25-44", "25-44", "25-44", "25-44", "25-44", "25-44", "25-44",
"45-64", "45-64", "45-64", "45-64", "45-64", "45-64", "45-64",
"45-64", "65+", "65+", "65+", "65+", "65+", "65+", "65+", "65+"
), Race = c("White", "Black", "AmerIndian", "Asian", "Hispanic",
"MultipleRaces", "Other", "Unknown", "White", "Black", "AmerIndian",
"Asian", "Hispanic", "MultipleRaces", "Other", "Unknown", "White",
"Black", "AmerIndian", "Asian", "Hispanic", "MultipleRaces",
"Other", "Unknown", "White", "Black", "AmerIndian", "Asian",
"Hispanic", "MultipleRaces", "Other", "Unknown", "White", "Black",
"AmerIndian", "Asian", "Hispanic", "MultipleRaces", "Other",
"Unknown"), Count_Type = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = c("Initial", "Full"), class = "factor"), Total_Count = c(500,
1080, 11, 172, 2404, 105, 135, 272, 1012, 1610, 10, 326, 3051,
110, 502, 480, 3281, 4185, 34, 738, 10023, 147, 2060, 1907, 4453,
6361, 41, 695, 9250, 144, 2549, 2043, 4000, 3520, 22, 368, 3554,
83, 1182, 1354)), row.names = c(NA, -40L), class = c("tbl_df",
"tbl", "data.frame"))
And below is my messy plot. What can I add or change in order to have values not overlap? Different chart ideas are also welcome