2016-03-11 23 views
-1

我有我使用下面的代碼創建一個情節:扳動柱狀圖中的數字,使用ggplot

p <- ggplot(flexbooks, aes(x=SchoolYear, y=Count,fill=Type)) + geom_bar(stat="identity") + 
    geom_text(data=flexbooks,aes(label=Count),vjust=-1,hjust=0.5) 
p 

我碰到下面的情節:

enter image description here

我會喜歡在這裏翻轉數字。頂部顯示的必須位於底部,反之亦然。

任何幫助,將不勝感激。謝謝。

+3

你的問題不包含[重複的例子(http://stackoverflow.com/q/5963269/4303162)。因此很難理解你的問題並給你一個合適的答案。請提供您的數據(例如使用'dput()')或使用R中的示例數據集之一。另外,添加將您的問題重現到您的文章所需的最小代碼。 – Stibu

回答

0

嘗試扭轉的傳說:

p <- ggplot(flexbooks, aes(x=SchoolYear, y=Count,fill=Type)) + 
    geom_bar(stat="identity") + 
    geom_text(data=flexbooks,aes(label=Count),vjust=-1,hjust=0.5) + 
    guides(fill = guide_legend(reverse = TRUE))