2 回答

TA贡献1773条经验 获得超3个赞
通用(非ggplot特定)答案是reorder()根据其他列的某些功能来重置类别列中的因子水平。
## Examine the default factor order
levels(samp.data$fullname)
## Reorder fullname based on the the sum of the other columns
samp.data$fullname <- reorder(samp.data$fullname, rowSums(samp.data[-1]))
## Examine the new factor order
levels(samp.data$fullname)
attributes(samp.data$fullname)
然后使用原始问题中的代码重新绘制
md <- melt(samp.data, id=(c("fullname")))
temp.plot<-ggplot(data=md, aes(x=fullname, y=value, fill=variable) ) +
geom_bar()+
theme(axis.text.x=theme_text(angle=90)) +
labs(title = "Score Distribtion")
## ggsave(temp.plot,filename="test.png")
- 2 回答
- 0 关注
- 613 浏览
添加回答
举报