こちらを使うと、凡例の順序を逆にできます。
guides(color = guide_legend(reverse = TRUE))
例
通常はこちら。
library(ggplot2) ggplot(mtcars, aes(x = mpg, y = wt, color = factor(cyl))) + geom_point()

凡例の順序を逆にします。
guides(color = guide_legend(reverse = TRUE))
を使います。
ggplot(mtcars, aes(x = mpg, y = wt, color = factor(cyl))) + geom_point() + guides(color = guide_legend(reverse = TRUE))

おわりに
今回の記事はこちらのサイトを参考にしました。

Sort legend in ggplot2
I have produced a stacked percent barplot from the following data, which is in a csv file,
,ONE,TWO,THREE
1,2432,420,18
2,276,405,56
3,119,189,110
4,90,163,140...
では。
—
YouTube: ミサキさん
問い合わせ先
Mail: caprico.aries@gmail.com
Twitter: https://twitter.com/caprico_aries(無言フォローもお気軽に)
コメント