I made some lovely bar charts with the basic plot function in R. However, my boss told me she would like them done in ggplot using colorbrewer colors.
Well, 2 days later, I finally made the following:
I used the following code:
ggplot(data, aes(x=edscat,y=studynum)) + geom_bar(aes(fill= colorRampPalette(brewer.pal(6,"Accent"))(6)),stat = "identity") +
labs(title="Study Type", x="EDS Category", y="Number of Studies") +
theme(plot.title = element_text(size=30,hjust = 0.5))+theme(legend.title=element_blank()) + theme(panel.background = element_rect(fill = 'white')) +
theme(axis.line = element_line(color="black", size = 0.5)) + theme(axis.text.x= element_text(face="bold", size=12)) +
theme(axis.text.y = element_text(face="bold", size=12)) + scale_y_continuous(breaks=seq(0,80,10)) + scale_x_continuous(breaks=seq(0,6,1)) +
theme(axis.title.x = element_text(face="bold", size=12)) + theme(axis.title.y = element_text(face="bold", size=12)) +
theme(legend.position="right") + scale_fill_discrete(name = "Categories", labels = c("Water Quantity","Biota and Biodiversity","Water Quality","Landcover","Geomorphology","Connectivity and Fragmentation")) +
theme(legend.justification=c(1,0),legend.position=c(0.95, 0.70),panel.border = element_rect(colour = "black", fill=NA),legend.box.background = element_rect(colour = "black"), legend.background = element_rect(linetype = "solid", colour = "black"),
)
I love the look of it, but I had to reorder the labels in order to get them to match the colors. The basic bar chart function will match the colors to the labels, as well as label them top to bottom, from the left to right reading of the x axis. Please see the next image: