如何按月而不是按字母顺序制作传奇?

时间:2014-08-26 20:10:25

标签: r ggplot2

我有这个数据框

months  regions frequency
April   Appalachians    4424
August  Appalachians    1435
December    Appalachians    3369
February    Appalachians    2649
January Appalachians    3868
July    Appalachians    1683
June    Appalachians    2290
March   Appalachians    6031
May Appalachians    2421
November    Appalachians    2304
October Appalachians    2184
September   Appalachians    2444

我正在使用此代码进行策划

ggplot(mcount_appalachian, aes(x=regions, y=frequency, fill=months)) +
  scale_fill_manual(name = "Months",values=bwPalette(12))+
  geom_bar(colour="black",stat="identity", position="dodge")+
  geom_text(aes(ymax=frequency,label = paste(sprintf("%s", frequency)),
                hjust= 0.5,vjust=-1,group=months),
            size = 2, position = position_dodge(width=.9)) +
  facet_wrap(~regions)+
  theme_bw()+
  theme(legend.key = element_rect(colour = "black")) +
  guides(fill = guide_legend(override.aes = list(colour = NULL)))

这是我得到的数字。但我希望这个传说能够连续一个月(如Jan,feb ... Dec)而不是按字母顺序排列。

我该怎么做?

enter image description here

0 个答案:

没有答案