我在 ggplot 中制作了一个条形图,但纯粹出于审美原因,我想更改 Legend 类别的顺序。这是我的脚本:
library(ggplot2)
df <- data.frame(Month = c(4, 5, 6, 7, 8, 9, 10, 11),
variable = rep(c("Outlier", "NOutlier"), 4),
value = c(8, 9, 10, 5, 12, 13, 9, 10))
hist_overall <- ggplot(df, aes(x = Month, y = value, fill = variable)) +
geom_bar(stat = "identity") +
scale_fill_manual("Legenda", values = c("Outlier" = "#1260AB", "NOutlier" = "#009BFF"))
hist_overall
我不想对数据做任何事情,我只想更改图例顺序,以便在浅蓝色类别“NOutlier”之上描绘深蓝色类别“Outlier”。
有人知道我这样做的快速方法吗?