Please see my figure in the image. Currently, the x-axis is ordered by the total number of nests per “bee of wasp group”, so forested and open margin values (see legend) are added together. I want to instead order the x-axis by just the number of nests (y-value) in the open margin category. How would I do this? My current ggplot code is included. Dataset not necessary for this question.
ggplot(straw.gg.sum, aes(fill = Margin, y = sumNests, x = reorder(str_to_title(straw.gg.sum$Builder), sumNests, decreasing = TRUE)))
+ geom_bar(stat = "identity",position = "dodge") +xlab("Bee or wasp group")
+ ylab("Total nests")
+ theme(axis.text.x = element_text(angle = 45, vjust = 0.9, hjust=1, face = "italic", size = 8), panel.background = element_blank(), axis.line = element_line(colour = "black"), text = element_text(size = 11))
+ scale_fill_manual("Margin", values = c("forested" = "yellowgreen", "open" = "cyan3"))
See ggplot code (included in question)
New contributor
stinkymushu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.