Below is a graph. How do I reverse the Y axis , so it reads down "a b" instead of "b a", while leaving the X axis alone?
Code:
library(ggplot2)
levels = ordered(c('a', 'b'))
data = data.frame(x=ordered(c('a', 'a', 'b', 'b'), levels=levels),
y=ordered(c('a', 'b', 'a', 'b'), levels=levels),
prob=c(0.3, 0.7, 0.4, 0.6))
ggplot(data, aes(x, y)) + geom_tile(aes(fill=prob))
I figured this out.
ggplot(data, aes(x, ordered(y, levels=rev(levels)))) +
geom_tile(aes(fill=prob))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With