Hi I'm working in R for a new job and am creating a box plot that displays levels of sample contamination. I have got the graph looking the way I want, but I can't get the legend to move to the side without disappearing and the x-axis labels falling off the bottom.
My code looks like this:
#adds padding to the inner margin of the graph, allows legend and labels to fit
par(mar=c(10,5,3,10))
stackedGraphGOOD = barplot(as.matrix(goodKrakenData),
col = c("DODGERBLUE", "GREEN3", "RED"),
ylab = "Percent", border = NA, axis.lty = 1, cex.axis = 1,
main = "Kraken Quality Percentages",
legend.text = c("Unclassified", "Family", "Other"),
args.legend = list(x = 14, bty='y'), las = 2)
#allows me to adjust the placement of the x-axis label
title(xlab = "Animal ID", line = 9)
and I get a graph that looks like this:
I needed to adjust the inner and outer margins of the graph for it to display properly
taxonomy ID1 ID2 ID3
unclassified 19 5 10
Other 0.0003 0.0006 0.08
primaryFamily 80.9997 94.9994 89.92