stack_discrete()
Stacked bar
stack_discretev(data) +
# add bar for total
ggalign(rowSums, size = 0.1) +
geom_tile(aes(y = 1, fill = value)) +
scale_fill_viridis_c(name = "Total") +
# add bar for catogery
ggalign(factor(category), size = 0.1) +
geom_tile(aes(y = 1, fill = value)) +
scale_fill_brewer(palette = "Set2", name = "Category") -
scale_y_continuous(breaks = NULL, name = NULL) +
ggalign() +
geom_bar(aes(y = value, fill = .column_names),
stat = "identity", position = position_fill()
) +
scale_fill_brewer(palette = "Dark2", name = "Stacked Bar")