I know my question looks similar to many others but I had not founded the solution to my problem.
I have these two bar charts, and I want to order the two charts by the value of "ALPHA".
In my desired output, the values on the y-axis are: E,D, B,C, A
This is my dataset and the code for the plot:
set.seed(123)
df <- data.frame(
X = c(runif(5, 0,1000), runif(5, -500,500)),
Y = rep(LETTERS[1:5],2),
Z = c(rep("ALPHA",5),rep("BETA",5))
)
ggplot(df, aes(y = Y, x = X)) +
geom_bar(stat = "identity", fill = "steelblue") +
facet_grid(. ~ Z, scales = "free_x", space = "free_x") +
labs(y = "", x = "", title = "This is my visualization")
Thanks in advance