how do you order Months in ggplot

  • Use reorder to arrange your axis labels. I create a new column with month index.
  • geom_text to add text. Maybe you should play with text size.
  • scale_fill_gradientn to change fill color. See also scale_fill_gradientn

enter image description here

dat.m <- data.frame(Month=months(seq(as.Date("2000/1/1"), 
              by = "month", length.out = 12)),month.id = 1:12)

yy <- merge(yy,dat.m)
library(ggplot2)
ggplot(yy ,aes(reorder(Month,month.id), Year, fill=Peak_Logons)) +
    geom_tile() + 
    theme_bw() + 
    guides(fill = guide_legend(keywidth = 5, keyheight = 1)) + 
    theme(axis.text.x = element_text(size=10, angle=45, hjust=1)) +
    geom_text(aes(label=paste(Peak_Logons,format(Time,"%H"),sep='-'))) +
    scale_fill_gradient(low = "yellow",  high = "red")

You seem to consider months an ordered factor. You should make it one in R:

Month = c("April", "April", 
          "April", "April", "April", "April", "August", "August", "August", 
          "August", "August", "August", "December", "December", "December", 
          "December", "December", "December", "February", "February", "February", 
          "February", "February", "February", "January", "January", "January", 
          "January", "January", "January")

Month.ordered <- ordered(Month, month.name)
#[1] April    April    April    April    April    April    August   August   August   August   August   August   December December December December
#[17] December December February February February February February February January  January  January  January  January  January 
#Levels: January < February < March < April < May < June < July < August < September < October < November < December