r - ggplot在barplot中更改堆栈顺序
问题描述
我有以下情节,我需要将蓝条(失败)置于顶部。我试过了,order
但没有做出预期的改变。订单有什么问题?
ggplot(a, aes(fill=Var1, y=value, x=Var2, order("pass","fail")))
+geom_bar( stat="identity", position="fill") + labs(x = "Subject", y="Pass/Fail Percentage")
+ guides(fill=guide_legend(title="Result"))
这是我的数据
Var1 Var2 value
pass Maths 865
fail Maths 135
pass Reading 910
fail Reading 90
pass Writing 886
fail Writing 114