I would like to create a stacked horizontal barchart that uses defined breaks in the stacks. I would also like this stacked barchart to use percentages rather than counts.
threat_status total species
LC 300 bird
VU 20 bird
EX 100 mammal
LC 0 bird
LC 100 bird
This is what I have so far:
bar3 <- ggplot(species_borders, aes(x = threat_status, fill = Total)) +
geom_bar(aes(y = (..count..)/sum(..count..))) +
coord_flip +
scale_y_continuous(labels=percent) +
ylab("Percentage of species") +
xlab("Threat status") +
geom_col(position = "stack", width = 0.4)
scale_fill_discrete(name = "Borders crossed", breaks = c("3-300","2-1","0"), labels = c("3-300","2-1","0"))
This works, but doesn't show the breaks or colours.
My expected result would be staked barchart, with y-axis showing the percentage of species, x-axis is the threat_status, and the stakes are 3 different colours with breaks "0", "1-2", "3-300".