I did the following stacked bar many times by specifying the factor order. Today I've tried it again. The legend respects the ordering manually defined, but the bars appear in the opposite way (from the last level to the first). For example, the legend is as follow : Factor1, Factor2, Factor3. But the first bar on the left is Factor3, then Factor2 and Factor1.
I have completely reinstalled R and RStudio, but nothing changed.
data<-read.table('file.txt', header=TRUE, sep="\t")
data$Genus<-factor(data$Genus, levels=c('Factor1','Factor2','Factor3'))
colors<-c('color1','color2','color3')
c<- ggplot(data_gathered, aes(x=Materiel, y=Log, fill=Genus2))
c <- c + geom_bar(stat = "identity") +
theme_classic()+
theme(legend.text=element_text(face="italic", size=12))+
theme(legend.title=element_text(face="bold.italic", size=12))+
theme(strip.background = element_blank())+
scale_y_continuous(limits=c(0,10))+
scale_fill_manual(values = colors) +
labs(y='axis title', x=element_blank(), fill='Legend') +
coord_flip()
c
Is it a problem with my software ? What could I do?