R - order of legend ggplot
问题 I have the following data frame: Author<-c("University","Office", "School","University","Office", "School","University","Office", "School") Typ<-c("Text", "Text", "Text","Data", "Data","Data", "List", "List", "List") Number<-c("3","1","6","4","4","2","8","1","1") df<-data.frame(Typ,Author,Number) If I apply: ggplot(df, aes(x=Author, y=Number, fill=Typ)) + geom_bar(stat='identity') + coord_flip() then I get a stacked bar plot where the bars are orders in the order of the date frame, i.e. Text