I am creating bar plots in qplot, (ggplot2
function in R) and have two problems.
When I rotate the x-axis scale values by 90 degrees they no longer centre under the columns and tick marks. This doesn't seem like much of an issue with just a few columns, but I'm creating multiple plots with 12 columns using facet-wrap and then the offset becomes very noticeable (the scale values then sit between the columns).
The x-axis values are dates as factors. How can I order the columns by date rather than by alphabetical order. If I convert the dates to date format they will order correctly but will space out on a continuous date scale which I dont want. This could be a problem with any type of x-axis data of course.
Here's a dummy dataset and R code to illustrate the problems.
date <- c("Oct 2006","Feb 2007","Nov 2007","Feb 2008","Oct 2008","Feb 2009","Nov 2009")
count <- c(23,54,12,78,23,34,12)
df <- data.frame(date,count)
qplot(x=date, y=count, data=df, geom="bar", stat="identity") + theme (axis.text.x = element_text(angle = 90,))