I am trying to reverse the order of the fill factor on the graph, i.e. The 0.5-1 class, must be at the top of the bar.. and then in descending order
gruppo <- c("TM", "TM","TM","TM", "PM", "PM","PM","PM")
valor <-c(1,4,237,3433,1,3,240,3700)
class <- c(">1", "0.5-1", "0.1-0.5", "<0.1")
df <- data.frame(Trait=gruppo, n_windows=valor, var_exp =class)
library(ggplot2)
ggplot(df, aes(x= Trait, y=n_windows, fill=var_exp)) + geom_bar(stat= "identity")
I tried the reorder function, but don't work
ggplot(df, aes(x=reorder(Trait, y=n_windows), fill=var_exp)) + geom_bar(stat= "identity")