In below plot , 1) How to align category 'A' to axis x (axis y start from 0)?
2) How to change sub_category fill color ? want change to 'pink' (whis the color samilar to category color) . Anyone can help?
library(tidyverse)
plot_data <- data.frame(category=c('A','A','B','C'),
sub_category=c('a1','a2','b1','c1'),
value=c(6,12,3,2))
plot_data %>% mutate(sub_category=if_else(category=='A',
sub_category,category)) %>%
pivot_longer(names_to = 'title',values_to ='cat_region',-value) %>%
filter(!(title=='sub_category'&cat_region %in% c('B','C') )) %>%
group_by(title,cat_region) %>%
summarise(value_sum=sum(value)) %>%
ggplot(aes(x=title,y=value_sum,fill=cat_region,
group=interaction(title,cat_region)))+geom_col()